From fd09713be418eef0f0dacf7ad2a450b0a9a5250e Mon Sep 17 00:00:00 2001 From: GringoElPepito Date: Thu, 25 Apr 2024 23:43:47 +0200 Subject: [PATCH] Last push before exam --- dump.sql | 522 ++++++++++++++++++ .../dashboard/admin/doctor/detail/index.jsx | 8 +- .../admin/doctor/item-list/index.jsx | 2 +- src/components/dashboard/admin/index.jsx | 12 +- .../dashboard/admin/patient/detail/index.jsx | 34 ++ .../dashboard/admin/patient/index.jsx | 40 ++ .../admin/patient/item-list/index.jsx | 24 + src/components/dashboard/admin/user/index.jsx | 38 +- .../dashboard/admin/user/item-list/index.jsx | 21 +- .../dashboard/doctor/appointment/index.jsx | 7 +- .../doctor/appointment/item-list/index.jsx | 4 +- .../item-list/prescription-button.jsx | 7 + .../appointment/prescription-menu/index.jsx | 91 +++ src/components/dashboard/doctor/index.jsx | 2 +- .../dashboard/list-display/index.jsx | 4 +- .../dashboard/menu-display/index.jsx | 4 +- src/components/dashboard/patient/index.jsx | 2 +- .../dashboard/patient/prescription/index.jsx | 38 +- .../patient/prescription/item-list/index.jsx | 16 + src/config.sample.js | 14 +- 20 files changed, 859 insertions(+), 31 deletions(-) create mode 100644 dump.sql create mode 100644 src/components/dashboard/admin/patient/detail/index.jsx create mode 100644 src/components/dashboard/admin/patient/item-list/index.jsx create mode 100644 src/components/dashboard/doctor/appointment/item-list/prescription-button.jsx create mode 100644 src/components/dashboard/doctor/appointment/prescription-menu/index.jsx create mode 100644 src/components/dashboard/patient/prescription/item-list/index.jsx diff --git a/dump.sql b/dump.sql new file mode 100644 index 0000000..d659e47 --- /dev/null +++ b/dump.sql @@ -0,0 +1,522 @@ +-- MariaDB dump 10.19 Distrib 10.11.6-MariaDB, for debian-linux-gnu (x86_64) +-- +-- Host: localhost Database: hsp_gdh +-- ------------------------------------------------------ +-- Server version 10.11.6-MariaDB-0+deb12u1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `appointments` +-- + +DROP TABLE IF EXISTS `appointments`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `appointments` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `patient_id` int(10) unsigned NOT NULL, + `doctor_id` int(10) unsigned NOT NULL, + `service_id` int(10) unsigned NOT NULL, + `hospital_id` int(10) unsigned DEFAULT NULL, + `room_id` int(10) unsigned DEFAULT NULL, + `date` date NOT NULL, + `time` time NOT NULL, + `status` enum('Confirmed','Completed','Absent','Cancelled by Patient','Cancelled by Doctor') NOT NULL, + PRIMARY KEY (`id`), + KEY `ap_patient_id_idx` (`patient_id`), + KEY `ap_doctor_id_idx` (`doctor_id`), + KEY `ap_service_id_idx` (`service_id`), + KEY `ap_hospital_id_idx` (`hospital_id`), + KEY `ap_room_id_idx` (`room_id`), + CONSTRAINT `ap_doctor_id` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ap_hospital_id` FOREIGN KEY (`hospital_id`) REFERENCES `hospitals` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ap_patient_id` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ap_room_id` FOREIGN KEY (`room_id`) REFERENCES `rooms` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ap_service_id` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `appointments` +-- + +LOCK TABLES `appointments` WRITE; +/*!40000 ALTER TABLE `appointments` DISABLE KEYS */; +INSERT INTO `appointments` VALUES +(2,1,3,13,1,NULL,'2024-04-26','12:00:00','Confirmed'); +/*!40000 ALTER TABLE `appointments` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `bans` +-- + +DROP TABLE IF EXISTS `bans`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bans` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `reason` text NOT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `bn_user_id_idx` (`user_id`), + CONSTRAINT `bn_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `bans` +-- + +LOCK TABLES `bans` WRITE; +/*!40000 ALTER TABLE `bans` DISABLE KEYS */; +/*!40000 ALTER TABLE `bans` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `companies` +-- + +DROP TABLE IF EXISTS `companies`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `companies` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `code` varchar(2) NOT NULL, + `logo` varchar(255) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `companies` +-- + +LOCK TABLES `companies` WRITE; +/*!40000 ALTER TABLE `companies` DISABLE KEYS */; +INSERT INTO `companies` VALUES +(1,'Medical Test','MT',NULL); +/*!40000 ALTER TABLE `companies` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `doctors` +-- + +DROP TABLE IF EXISTS `doctors`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `doctors` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `email` varchar(255) NOT NULL, + `phone` varchar(20) NOT NULL, + `speciality` varchar(255) NOT NULL, + `status` enum('Available','Absent','Unavailable') NOT NULL, + `is_verified` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + UNIQUE KEY `uc_doctor_user_id` (`user_id`), + KEY `dt_user_id_idx` (`user_id`), + CONSTRAINT `dt_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `doctors` +-- + +LOCK TABLES `doctors` WRITE; +/*!40000 ALTER TABLE `doctors` DISABLE KEYS */; +INSERT INTO `doctors` VALUES +(1,2,'test2@gmail.com','0123456789','Ophtalmo','Available',1), +(3,4,'doc1@doc.com','0123456789','TEST','Available',1); +/*!40000 ALTER TABLE `doctors` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `hospital_doctors` +-- + +DROP TABLE IF EXISTS `hospital_doctors`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `hospital_doctors` ( + `hospital_id` int(10) unsigned NOT NULL, + `doctor_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`hospital_id`,`doctor_id`), + KEY `hd_hospital_id_idx` (`hospital_id`), + KEY `hd_doctor_id_idx` (`doctor_id`), + CONSTRAINT `hd_doctor_id` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON UPDATE CASCADE, + CONSTRAINT `hd_hospital_id` FOREIGN KEY (`hospital_id`) REFERENCES `hospitals` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `hospital_doctors` +-- + +LOCK TABLES `hospital_doctors` WRITE; +/*!40000 ALTER TABLE `hospital_doctors` DISABLE KEYS */; +INSERT INTO `hospital_doctors` VALUES +(1,1), +(1,3); +/*!40000 ALTER TABLE `hospital_doctors` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `hospitals` +-- + +DROP TABLE IF EXISTS `hospitals`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `hospitals` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `company_id` int(10) unsigned NOT NULL, + `name` varchar(255) NOT NULL, + `code` varchar(3) NOT NULL, + `country` varchar(255) NOT NULL, + `region` varchar(255) NOT NULL, + `city` varchar(255) NOT NULL, + `address` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + KEY `hs_company_id_idx` (`company_id`), + CONSTRAINT `hs_company_id` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `hospitals` +-- + +LOCK TABLES `hospitals` WRITE; +/*!40000 ALTER TABLE `hospitals` DISABLE KEYS */; +INSERT INTO `hospitals` VALUES +(1,1,'Hopital Sud Paris','HSP','France','Île de France','Paris','4 Rue Ambroise Paré'); +/*!40000 ALTER TABLE `hospitals` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `patients` +-- + +DROP TABLE IF EXISTS `patients`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `patients` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `date_of_birth` date NOT NULL, + `gender` enum('M','F','O') NOT NULL, + `address` varchar(255) NOT NULL, + `social_security_number` varchar(128) NOT NULL, + `insurance_number` varchar(128) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `uc_user_id` (`user_id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `patients` +-- + +LOCK TABLES `patients` WRITE; +/*!40000 ALTER TABLE `patients` DISABLE KEYS */; +INSERT INTO `patients` VALUES +(1,1,'2003-03-03','M','2 rue du test','104099307303413','123456'); +/*!40000 ALTER TABLE `patients` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `prescriptions` +-- + +DROP TABLE IF EXISTS `prescriptions`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `prescriptions` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `patient_id` int(10) unsigned NOT NULL, + `doctor_id` int(10) unsigned NOT NULL, + `appointment_id` int(10) unsigned NOT NULL, + `content` text NOT NULL, + PRIMARY KEY (`id`), + KEY `prescriptions_patient_idx` (`patient_id`), + KEY `prescriptions_doctor_idx` (`doctor_id`), + KEY `prescriptions_appointment_idx` (`appointment_id`), + CONSTRAINT `prescriptions_appointment_id` FOREIGN KEY (`appointment_id`) REFERENCES `appointments` (`id`) ON UPDATE CASCADE, + CONSTRAINT `prescriptions_doctor_id` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON UPDATE CASCADE, + CONSTRAINT `prescriptions_patient_id` FOREIGN KEY (`patient_id`) REFERENCES `patients` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `prescriptions` +-- + +LOCK TABLES `prescriptions` WRITE; +/*!40000 ALTER TABLE `prescriptions` DISABLE KEYS */; +INSERT INTO `prescriptions` VALUES +(8,1,3,2,'Test en légende'); +/*!40000 ALTER TABLE `prescriptions` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `roles` +-- + +DROP TABLE IF EXISTS `roles`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `roles` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `user_bitfield` int(10) unsigned NOT NULL, + `role_bitfield` int(10) unsigned NOT NULL, + `verification_code_bitfield` int(10) unsigned NOT NULL, + `ban_bitfield` int(10) unsigned NOT NULL, + `patient_bitfield` int(10) unsigned NOT NULL, + `doctor_bitfield` int(10) unsigned NOT NULL, + `service_bitfield` int(10) unsigned NOT NULL, + `company_bitfield` int(10) unsigned NOT NULL, + `hospital_bitfield` int(10) unsigned NOT NULL, + `room_bitfield` int(10) unsigned NOT NULL, + `appointment_bitfield` int(10) unsigned NOT NULL, + `prescription_bitfield` int(10) unsigned DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `r_name_idx` (`name`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `roles` +-- + +LOCK TABLES `roles` WRITE; +/*!40000 ALTER TABLE `roles` DISABLE KEYS */; +INSERT INTO `roles` VALUES +(1,'Admin',7,7,7,7,7,7,7,7,7,7,7,7), +(2,'Doctor',0,0,0,0,1,1,1,1,1,1,0,7), +(3,'Patient',0,0,0,0,0,1,1,1,1,1,0,1); +/*!40000 ALTER TABLE `roles` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `rooms` +-- + +DROP TABLE IF EXISTS `rooms`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `rooms` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `hospital_id` int(10) unsigned NOT NULL, + `name` varchar(255) NOT NULL, + `code` varchar(3) NOT NULL, + `floor` int(10) unsigned NOT NULL, + `room_number` int(10) unsigned NOT NULL, + `room_type` enum('General Ward','Private','Intensive Care Unit','Labor and Delivery','Operating','Recovery','Isolation','Emergency','Imaging','Procedure','Physical Therapy','Consultation') NOT NULL, + PRIMARY KEY (`id`), + KEY `ch_hospital_id_idx` (`hospital_id`), + CONSTRAINT `ch_hospital_id` FOREIGN KEY (`hospital_id`) REFERENCES `hospitals` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `rooms` +-- + +LOCK TABLES `rooms` WRITE; +/*!40000 ALTER TABLE `rooms` DISABLE KEYS */; +/*!40000 ALTER TABLE `rooms` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `service_doctors` +-- + +DROP TABLE IF EXISTS `service_doctors`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `service_doctors` ( + `service_id` int(10) unsigned NOT NULL, + `doctor_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`service_id`,`doctor_id`), + KEY `sd_service_id_idx` (`service_id`), + KEY `sd_doctor_id_idx` (`doctor_id`), + CONSTRAINT `sd_doctor_id` FOREIGN KEY (`doctor_id`) REFERENCES `doctors` (`id`) ON UPDATE CASCADE, + CONSTRAINT `sd_service_id` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `service_doctors` +-- + +LOCK TABLES `service_doctors` WRITE; +/*!40000 ALTER TABLE `service_doctors` DISABLE KEYS */; +INSERT INTO `service_doctors` VALUES +(8,1), +(9,1), +(10,1), +(11,1), +(12,1), +(13,3), +(14,3); +/*!40000 ALTER TABLE `service_doctors` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `services` +-- + +DROP TABLE IF EXISTS `services`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `services` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `description` text NOT NULL, + `price` decimal(10,2) NOT NULL, + `open_time` time NOT NULL, + `close_time` time NOT NULL, + `duration` time NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `services` +-- + +LOCK TABLES `services` WRITE; +/*!40000 ALTER TABLE `services` DISABLE KEYS */; +INSERT INTO `services` VALUES +(8,'Chirurgie','Service de visio',100.00,'08:00:00','20:00:00','02:00:00'), +(9,'Mdecine','Service de laboratoire',50.00,'08:00:00','18:30:00','00:30:00'), +(10,'Cancrologie','Service de cancrologie',75.00,'08:00:00','18:30:00','01:00:00'), +(11,'Maternit','Service de maternit',150.00,'08:00:00','18:30:00','02:00:00'), +(12,'Imagerie mdical','Service d\'imagerie',75.00,'08:00:00','18:30:00','01:00:00'), +(13,'Urgences','Service d\'urgences',25.00,'08:00:00','18:30:00','00:30:00'), +(14,'TEST','test',100.00,'08:00:00','18:30:00','02:00:00'); +/*!40000 ALTER TABLE `services` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user_roles` +-- + +DROP TABLE IF EXISTS `user_roles`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `user_roles` ( + `user_id` int(10) unsigned NOT NULL, + `role_id` int(10) unsigned NOT NULL, + PRIMARY KEY (`user_id`,`role_id`), + KEY `ur_user_id_idx` (`user_id`), + KEY `ur_role_id_idx` (`role_id`), + CONSTRAINT `ur_role_id` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON UPDATE CASCADE, + CONSTRAINT `ur_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user_roles` +-- + +LOCK TABLES `user_roles` WRITE; +/*!40000 ALTER TABLE `user_roles` DISABLE KEYS */; +INSERT INTO `user_roles` VALUES +(1,3), +(2,2), +(3,1), +(3,2), +(4,2); +/*!40000 ALTER TABLE `user_roles` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `users` +-- + +DROP TABLE IF EXISTS `users`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `users` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `first_name` varchar(64) NOT NULL, + `last_name` varchar(64) NOT NULL, + `username` varchar(64) NOT NULL, + `password` varchar(255) NOT NULL, + `email` varchar(128) NOT NULL, + `email_verified` tinyint(1) NOT NULL DEFAULT 0, + `phone` varchar(32) DEFAULT 'None', + `phone_verified` tinyint(1) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `users` +-- + +LOCK TABLES `users` WRITE; +/*!40000 ALTER TABLE `users` DISABLE KEYS */; +INSERT INTO `users` VALUES +(1,'test','test','test','$argon2id$v=19$m=65536,t=2,p=1$V9dC6KrvrCE6/iPyBYFX3S2lfpRfkjaYS4GnI0PyQPc$vdLwtm9+pLcP6MdUiUVospAF1x8IfSkhYHFjtrS4SEc','test@gmail.com',0,'0123456789',0), +(2,'test','test','test2','$argon2id$v=19$m=65536,t=2,p=1$/ZYuaP+6KI0rXxcuGc6005Az84InOV9nEDWs2lpF5qk$mIp/KBTArI1sLCyEeY92zu9TRHrPq/mT8mTFyBYehVo','test2@gmail.com',0,'0123456789',0), +(3,'admin','admin','admin','$argon2id$v=19$m=65536,t=2,p=1$229wVYU6lNYVcsdxxhJC+FFDTUYquOyc3G6utxRnPhw$p23Uzkt3tXjcLhrkxxSEePl54PY3HeTtQZ0FseCmtQs','admin@gmail.com',0,'0123456789',0), +(4,'doc','doc','doc1','$argon2id$v=19$m=65536,t=2,p=1$CszRzDJRP/oksX8fyr9oXyqclqf8a+mOiHS0vcImQ+k$Mabh4b3qk9WgGdaotqwuBwOJYuOWEsvsSdgRwy6mHqg','doc@doc.com',0,'0123456789',0); +/*!40000 ALTER TABLE `users` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `verification_codes` +-- + +DROP TABLE IF EXISTS `verification_codes`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `verification_codes` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `user_id` int(10) unsigned NOT NULL, + `verification_code` varchar(255) NOT NULL, + `type` varchar(32) NOT NULL, + `created_at` timestamp NOT NULL DEFAULT current_timestamp(), + PRIMARY KEY (`id`), + KEY `mv_user_id_idx` (`user_id`), + CONSTRAINT `mv_user_id` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `verification_codes` +-- + +LOCK TABLES `verification_codes` WRITE; +/*!40000 ALTER TABLE `verification_codes` DISABLE KEYS */; +/*!40000 ALTER TABLE `verification_codes` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2024-04-25 21:40:49 \ No newline at end of file diff --git a/src/components/dashboard/admin/doctor/detail/index.jsx b/src/components/dashboard/admin/doctor/detail/index.jsx index f472bb3..cd3d3d9 100644 --- a/src/components/dashboard/admin/doctor/detail/index.jsx +++ b/src/components/dashboard/admin/doctor/detail/index.jsx @@ -23,12 +23,12 @@ function DetailMenu({user,detail,setDetail}) {

Détails

-

Nom: {data.first_name}

-

Prénom: {data.last_name}

+

Prénom: {data.first_name}

+

Nom: {data.last_name}

Email Perso: {data.email}

Téléphone Perso: {data.phone}

-

Email Perso: {detail.email}

-

Téléphone Perso: {detail.phone}

+

Email Pro: {detail.email}

+

Téléphone Pro: {detail.phone}

Spécialité: {detail.speciality}

Statut: {detail.status}

Vérifié: {detail.is_verified ? "Oui" : "Non"}

diff --git a/src/components/dashboard/admin/doctor/item-list/index.jsx b/src/components/dashboard/admin/doctor/item-list/index.jsx index fdcd139..77bf630 100644 --- a/src/components/dashboard/admin/doctor/item-list/index.jsx +++ b/src/components/dashboard/admin/doctor/item-list/index.jsx @@ -2,7 +2,7 @@ import { post } from "../../../../../modules/fetchManager"; import ModifyButton from "../../../modify-button"; import DeleteButton from "../../../delete-button"; -export function ItemList({ item, setDeleteMenu, setModifyMenu, user, setDetailMenu }) { +function ItemList({ item, setDeleteMenu, setModifyMenu, user, setDetailMenu }) { const onClick = () => { post('doctors/'+item.id+'/validate', {doctor_id: item.id}, user.token) diff --git a/src/components/dashboard/admin/index.jsx b/src/components/dashboard/admin/index.jsx index 85a05fb..3d9ef48 100644 --- a/src/components/dashboard/admin/index.jsx +++ b/src/components/dashboard/admin/index.jsx @@ -10,12 +10,12 @@ function Admin({user,setUser}) { {page:"home",name:"Accueil"}, config.appointmentOn ? {page:"appointment",name:"Rendez-vous"} : null, config.prescriptionOn ? {page:"prescription",name:"Préscriptions"} : null, - {page:"medical-file",name:"Dossier Médical"}, - {page:"user",name:"Utilisateurs"}, - {page:"doctor",name:"Docteurs"}, - {page:"patient",name:"Patients"}, - {page:"hospital",name:"Hôpitaux"}, - {page:"service",name:"Services"}, + config.medicalFileOn ? {page:"medical-file",name:"Dossier Médical"} : null, + config.adminUserOn ? {page:"user",name:"Utilisateurs"} : null, + config.adminDoctorOn ? {page:"doctor",name:"Docteurs"} : null, + config.adminPatientOn ? {page:"patient",name:"Patients"} : null, + config.adminHospitalOn ? {page:"hospital",name:"Hôpitaux"} : null, + config.adminServiceOn ? {page:"service",name:"Services"} : null, config.profilOn ? {page:"profil",name:"Profil"} : null ]; diff --git a/src/components/dashboard/admin/patient/detail/index.jsx b/src/components/dashboard/admin/patient/detail/index.jsx new file mode 100644 index 0000000..8774e7a --- /dev/null +++ b/src/components/dashboard/admin/patient/detail/index.jsx @@ -0,0 +1,34 @@ +import ModalContainer from '../../../modal-container'; +import BackButton from '../../../back-button'; + +function DetailMenu({detail,setDetailMenu}) { + + const date = new Date(detail.date_of_birth); + + return( + + { +
+

Détails

+
+
+

Prénom: {detail.first_name}

+

Nom: {detail.last_name}

+

Email Perso: {detail.email}

+

Téléphone Perso: {detail.phone}

+

Date de naissance: {date.getDay() > 9 ? date.getDay() : "0"+date.getDay()}/{date.getMonth() > 9 ? date.getMonth() : "0"+date.getMonth()}/{date.getFullYear()}

+

Genre: {detail.gender}

+

Adresse: {detail.address}

+

Numéro de Sécurité Sociale: {detail.social_security_number}

+

Numéro d'assurance: {detail.insurance_number}

+
+ +
+
+ } +
+ ) + +} + +export default DetailMenu; \ No newline at end of file diff --git a/src/components/dashboard/admin/patient/index.jsx b/src/components/dashboard/admin/patient/index.jsx index 8564d0d..07eee3e 100644 --- a/src/components/dashboard/admin/patient/index.jsx +++ b/src/components/dashboard/admin/patient/index.jsx @@ -1,9 +1,49 @@ import HeadTitle from "../../head-title"; +import Container from "../../container"; +import ItemList from "./item-list"; +import MenuDisplay from "../../menu-display"; +import { useState, useEffect } from "react"; +import { get } from "../../../../modules/fetchManager"; +import DeleteMenu from "../../delete-menu"; +import DetailMenu from "./detail"; function Patient({user}) { + + const [deleteMenu, setDeleteMenu] = useState(null); + const [detailMenu, setDetailMenu] = useState(null); + + const [patients, setPatients] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + if(user && loading && !error && patients === null){ + get(`patients`, user.token) + .then((data) => { + setLoading(false); + if(data.status === 404) { + setError("Aucun patient trouvé"); + return; + } + + if(data.status === 500) { + setError("Erreur serveur, veuillez réessayer plus tard"); + return; + } + + setPatients(data.JSON); + }); + } + },[user]); + return(
+ + + {deleteMenu ? : null} + {detailMenu ? : null} +
) } diff --git a/src/components/dashboard/admin/patient/item-list/index.jsx b/src/components/dashboard/admin/patient/item-list/index.jsx new file mode 100644 index 0000000..41bbb14 --- /dev/null +++ b/src/components/dashboard/admin/patient/item-list/index.jsx @@ -0,0 +1,24 @@ +import DeleteButton from "../../../delete-button"; + +function ItemList({ item, setDeleteMenu, setDetailMenu}) { + + console.log(item) + + const date = new Date(item.date_of_birth); + + return ( +
+
+

{item.first_name} {item.last_name.toUpperCase()} - {item.username}

+

Genre : {item.gender}, Date de naissance : {date.getDay() > 9 ? date.getDay() : "0"+date.getDay()}/{date.getMonth() > 9 ? date.getMonth() : "0"+date.getMonth()}/{date.getFullYear()}

+

{item.email}, {item.phone}

+
+
+ + +
+
+ ); +} + +export default ItemList; \ No newline at end of file diff --git a/src/components/dashboard/admin/user/index.jsx b/src/components/dashboard/admin/user/index.jsx index e373e1a..373e081 100644 --- a/src/components/dashboard/admin/user/index.jsx +++ b/src/components/dashboard/admin/user/index.jsx @@ -1,10 +1,46 @@ import HeadTitle from "../../head-title"; import ItemList from "./item-list"; +import MenuDisplay from "../../menu-display"; +import { useEffect, useState } from "react"; +import { get } from "../../../../modules/fetchManager"; +import Container from "../../container"; +import DeleteMenu from "../../delete-menu"; function User({user}) { + + const [deleteMenu, setDeleteMenu] = useState(null); + + const [users, setUsers] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + if(user && loading && !error && users === null){ + get(`users`, user.token) + .then((data) => { + setLoading(false); + if(data.status === 404) { + setError("Aucun utilisateur"); + return; + } + + if(data.status === 500) { + setError("Erreur serveur, veuillez réessayer plus tard"); + return; + } + + setUsers(data.JSON); + }); + } + },[user]); + return( -
+
+ + + {deleteMenu ? : null} +
) } diff --git a/src/components/dashboard/admin/user/item-list/index.jsx b/src/components/dashboard/admin/user/item-list/index.jsx index 787e4c6..2cb2da5 100644 --- a/src/components/dashboard/admin/user/item-list/index.jsx +++ b/src/components/dashboard/admin/user/item-list/index.jsx @@ -1,7 +1,20 @@ -function ItemList({item, setDeleteMenu}) { -
- -
+import DeleteButton from "../../../delete-button"; + +function ItemList({ item, setDeleteMenu }) { + return ( +
+
+

{item.first_name} {item.last_name.toUpperCase()} - {item.username}

+

{item.email} - {item.email_verified ? 'Vérifié' : 'Non vérifié'}

+

{item.phone} - {item.phone_verified ? "Vérifié" : "Non vérifié"}

+
+
+
+ +
+
+
+ ); } export default ItemList; \ No newline at end of file diff --git a/src/components/dashboard/doctor/appointment/index.jsx b/src/components/dashboard/doctor/appointment/index.jsx index c3b5e2c..03fbe1b 100644 --- a/src/components/dashboard/doctor/appointment/index.jsx +++ b/src/components/dashboard/doctor/appointment/index.jsx @@ -4,12 +4,14 @@ import MenuDisplay from "../../menu-display"; import { useState, useEffect } from "react"; import { get } from "../../../../modules/fetchManager"; import DeleteMenu from "../../delete-menu"; +import PrescriptionMenu from "./prescription-menu"; function Appointment({user}) { const [appointments, setAppointments] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); + const [prescriptionMenu, setPrescriptionMenu] = useState(false); const [deleteMenu, setDeleteMenu] = useState(false); useEffect(() => { @@ -34,9 +36,10 @@ function Appointment({user}) { return (
- - + + { deleteMenu ? : null } + { prescriptionMenu ? : null }
); } diff --git a/src/components/dashboard/doctor/appointment/item-list/index.jsx b/src/components/dashboard/doctor/appointment/item-list/index.jsx index fde66ab..6e2b9b8 100644 --- a/src/components/dashboard/doctor/appointment/item-list/index.jsx +++ b/src/components/dashboard/doctor/appointment/item-list/index.jsx @@ -1,6 +1,7 @@ import DeleteButton from "../../../delete-button"; +import PrescriptionButton from "./prescription-button"; -function ItemList({item, setDeleteMenu}) { +function ItemList({item, setDeleteMenu, setPrescriptionMenu}) { const date = new Date(item.date); return (
@@ -10,6 +11,7 @@ function ItemList({item, setDeleteMenu}) {
{/* */} +
diff --git a/src/components/dashboard/doctor/appointment/item-list/prescription-button.jsx b/src/components/dashboard/doctor/appointment/item-list/prescription-button.jsx new file mode 100644 index 0000000..7f3e505 --- /dev/null +++ b/src/components/dashboard/doctor/appointment/item-list/prescription-button.jsx @@ -0,0 +1,7 @@ +function PrescriptionButton({setPrescriptionMenu,item}) { + return ( + + ); +} + +export default PrescriptionButton; \ No newline at end of file diff --git a/src/components/dashboard/doctor/appointment/prescription-menu/index.jsx b/src/components/dashboard/doctor/appointment/prescription-menu/index.jsx new file mode 100644 index 0000000..d25597e --- /dev/null +++ b/src/components/dashboard/doctor/appointment/prescription-menu/index.jsx @@ -0,0 +1,91 @@ +import { useState, useEffect } from 'react'; +import { get, post, put } from '../../../../../modules/fetchManager'; +import ModalContainer from '../../../modal-container'; +import BackButton from '../../../back-button'; +import SubmitButton from '../../../submit-button'; +import { useForm } from 'react-hook-form'; + +function PrescriptionMenu({setPrescriptionMenu, prescriptionMenu,user}) { + + const [prescription, setPrescription] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + const [request, setRequest] = useState(false); + const [content, setContent] = useState(null); + + useEffect(() => { + if(loading && !error && prescription === null){ + get(`prescriptions/appointments/${prescriptionMenu.id}`, user.token) + .then((data) => { + setLoading(false); + setRequest({function: post, url: 'prescriptions',message: "Préscription ajoutée avec succès"}); + if(data.status === 404) { + setError("Aucune préscription pour ce rendez-vous"); + return; + } + + if(data.status === 500) { + setError("Erreur serveur, veuillez réessayer plus tard"); + return; + } + + setRequest({function: put, url: `prescriptions/${data.JSON.id}`,message: "Préscription modifiée avec succès"}); + setPrescription(data.JSON); + setContent(data.JSON.content); + }); + } + },[user,prescription]); + + const onSubmit = (e) => { + e.preventDefault(); + e.stopPropagation(); + const data = { + content: content, + patient_id: prescriptionMenu.patient_id, + doctor_id: prescriptionMenu.doctor_id, + appointment_id: prescriptionMenu.id + } + request.function(request.url, data, user.token) + .then(data => { + setLoading(false); + if(data.status === 400) { + alert("Des champs n'ont pas été remplis correctement"); + return; + } + if(data.status === 500) { + alert("Erreur lors de l'ajout de la préscription"); + return; + } + alert(request.message); + }); + }; + + const onChange = (e) => { + setContent(e.target.value); + } + + return( + +
+
+

Ajout/Modification d'une préscription

+
+
+ {loading ?
Chargement...
: null} + {error ?
{error}
: null} +
+
+ + +
+
+ + +
+
+
+ ); +} + +export default PrescriptionMenu; \ No newline at end of file diff --git a/src/components/dashboard/doctor/index.jsx b/src/components/dashboard/doctor/index.jsx index eb7fa35..1a0ba4b 100644 --- a/src/components/dashboard/doctor/index.jsx +++ b/src/components/dashboard/doctor/index.jsx @@ -9,7 +9,7 @@ function Doctor({user, setUser}) { {page:"home",name:"Accueil"}, config.appointmentOn ? {page:"appointment",name:"Rendez-vous"} : null, config.prescriptionOn ? {page:"prescription",name:"Préscriptions"} : null, - {page:"medical-file",name:"Dossier Médical"}, + config.medicalFileOn ? {page:"medical-file",name:"Dossier Médical"} : null, config.profilOn ? {page:"profil",name:"Profil"} : null ]; diff --git a/src/components/dashboard/list-display/index.jsx b/src/components/dashboard/list-display/index.jsx index 338dcea..ec662bc 100644 --- a/src/components/dashboard/list-display/index.jsx +++ b/src/components/dashboard/list-display/index.jsx @@ -1,4 +1,4 @@ -function ListDisplay({data, ItemComponent, height = true, setDeleteMenu = null, setModifyMenu = null, user = null, setDetailMenu = null}) { +function ListDisplay({data, ItemComponent, height = true, setDeleteMenu = null, setModifyMenu = null, user = null, setDetailMenu = null,setPrescriptionMenu = null}) { const className = height ? "min-h-full h-fit py-5 w-full" : "h-fit py-5 w-full"; return(
@@ -6,7 +6,7 @@ function ListDisplay({data, ItemComponent, height = true, setDeleteMenu = null, { data.map((item,index) =>
  • - {} + {}
  • ) } diff --git a/src/components/dashboard/menu-display/index.jsx b/src/components/dashboard/menu-display/index.jsx index 4bcb938..ea6830b 100644 --- a/src/components/dashboard/menu-display/index.jsx +++ b/src/components/dashboard/menu-display/index.jsx @@ -2,12 +2,12 @@ import Container from "../container" import Loader from "../loader" import ListDisplay from "../list-display" -function MenuDisplay({loading, error, data, ItemList, setDeleteMenu = null, setModifyMenu = null,user = null,setDetailMenu = null}) { +function MenuDisplay({loading, error, data, ItemList, setDeleteMenu = null, setModifyMenu = null,user = null,setDetailMenu = null,setPrescriptionMenu = null}) { return( { loading ? : null } { error ?

    {error}

    : null } - { !error && !loading ? : null } + { !error && !loading ? : null }
    ) } diff --git a/src/components/dashboard/patient/index.jsx b/src/components/dashboard/patient/index.jsx index 56d9ee5..bfe9a19 100644 --- a/src/components/dashboard/patient/index.jsx +++ b/src/components/dashboard/patient/index.jsx @@ -9,7 +9,7 @@ function Patient({user,setUser}) { {page:"home",name:"Accueil"}, config.appointmentOn ? {page:"appointment",name:"Rendez-vous"} : null, config.prescriptionOn ? {page:"prescription",name:"Préscriptions"} : null, - {page:"medical-file",name:"Dossier Médical"}, + config.medicalFileOn ? {page:"medical-file",name:"Dossier Médical"} : null, config.profilOn ? {page:"profil",name:"Profil"} : null, ] diff --git a/src/components/dashboard/patient/prescription/index.jsx b/src/components/dashboard/patient/prescription/index.jsx index 98c2492..1d0bd71 100644 --- a/src/components/dashboard/patient/prescription/index.jsx +++ b/src/components/dashboard/patient/prescription/index.jsx @@ -1,9 +1,43 @@ import HeadTitle from "../../head-title"; +import { useEffect, useState } from "react"; +import { get } from "../../../../modules/fetchManager"; +import ListDisplay from "../../list-display"; +import ItemList from "./item-list"; + +function Prescription({user}) { + + const [prescription, setPrescription] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + if(user && loading && !error && prescription === null){ + get(`patients/@me/prescriptions`, user.token) + .then((data) => { + setLoading(false); + if(data.status === 404) { + setError("Aucune préscription pour ce rendez-vous"); + return; + } + + if(data.status === 500) { + setError("Erreur serveur, veuillez réessayer plus tard"); + return; + } + + setPrescription(data.JSON); + console.log(data.JSON); + }); + console.log(prescription); + } + },[user,prescription]); -function Prescription() { return ( -
    +
    + { loading ?

    Chargement...

    : null } + { error ?

    {error}

    : null } + { prescription ? : null }
    ); } diff --git a/src/components/dashboard/patient/prescription/item-list/index.jsx b/src/components/dashboard/patient/prescription/item-list/index.jsx new file mode 100644 index 0000000..9e6d903 --- /dev/null +++ b/src/components/dashboard/patient/prescription/item-list/index.jsx @@ -0,0 +1,16 @@ +function ItemList({item}) { + const date = new Date(item.date); + return( +
    +
    +

    {item.name} - {date.getDay() > 9 ? date.getDay() : "0"+date.getDay()}/{date.getMonth() > 9 ? date.getMonth() : "0"+date.getMonth()}/{date.getFullYear()},{item.time.substring(0,item.time.length-3)}

    +

    Dr.{item.first_name} {item.last_name}

    +
    +
    +

    {item.content}

    +
    +
    + ); +} + +export default ItemList; \ No newline at end of file diff --git a/src/config.sample.js b/src/config.sample.js index 984cc7c..af1a0f9 100644 --- a/src/config.sample.js +++ b/src/config.sample.js @@ -1,9 +1,15 @@ const config = { api: "http://127.0.0.1:3000/api", - prescriptionOn: true, - appointmentOn: true, - profilOn: true, - affectationOn: true, + prescriptionOn: false, + appointmentOn: false, + profilOn: false, + affectationOn: false, + medicalFileOn: false, + adminUserOn: false, + adminDoctorOn: false, + adminPatientOn: false, + adminHospitalOn: false, + adminServiceOn: false, } export default config; \ No newline at end of file