Last push before exam
This commit is contained in:
522
dump.sql
Normal file
522
dump.sql
Normal file
@@ -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
|
||||
@@ -23,12 +23,12 @@ function DetailMenu({user,detail,setDetail}) {
|
||||
<h2 className="text-2xl">Détails</h2>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
<p><span className="font-bold">Nom:</span> {data.first_name}</p>
|
||||
<p><span className="font-bold">Prénom:</span> {data.last_name}</p>
|
||||
<p><span className="font-bold">Prénom:</span> {data.first_name}</p>
|
||||
<p><span className="font-bold">Nom:</span> {data.last_name}</p>
|
||||
<p><span className="font-bold">Email Perso:</span> {data.email}</p>
|
||||
<p><span className="font-bold">Téléphone Perso:</span> {data.phone}</p>
|
||||
<p><span className="font-bold">Email Perso:</span> {detail.email}</p>
|
||||
<p><span className="font-bold">Téléphone Perso:</span> {detail.phone}</p>
|
||||
<p><span className="font-bold">Email Pro:</span> {detail.email}</p>
|
||||
<p><span className="font-bold">Téléphone Pro:</span> {detail.phone}</p>
|
||||
<p><span className="font-bold">Spécialité:</span> {detail.speciality}</p>
|
||||
<p><span className="font-bold">Statut:</span> {detail.status}</p>
|
||||
<p><span className="font-bold">Vérifié:</span> {detail.is_verified ? "Oui" : "Non"}</p>
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
];
|
||||
|
||||
|
||||
34
src/components/dashboard/admin/patient/detail/index.jsx
Normal file
34
src/components/dashboard/admin/patient/detail/index.jsx
Normal file
@@ -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(
|
||||
<ModalContainer>
|
||||
{
|
||||
<div>
|
||||
<h2 className="text-2xl">Détails</h2>
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="flex flex-col gap-4">
|
||||
<p><span className="font-bold">Prénom:</span> {detail.first_name}</p>
|
||||
<p><span className="font-bold">Nom:</span> {detail.last_name}</p>
|
||||
<p><span className="font-bold">Email Perso:</span> {detail.email}</p>
|
||||
<p><span className="font-bold">Téléphone Perso:</span> {detail.phone}</p>
|
||||
<p><span className="font-bold">Date de naissance:</span> {date.getDay() > 9 ? date.getDay() : "0"+date.getDay()}/{date.getMonth() > 9 ? date.getMonth() : "0"+date.getMonth()}/{date.getFullYear()} </p>
|
||||
<p><span className="font-bold">Genre:</span> {detail.gender}</p>
|
||||
<p><span className="font-bold">Adresse:</span> {detail.address}</p>
|
||||
<p><span className="font-bold">Numéro de Sécurité Sociale:</span> {detail.social_security_number}</p>
|
||||
<p><span className="font-bold">Numéro d'assurance:</span> {detail.insurance_number}</p>
|
||||
</div>
|
||||
<BackButton setMenu={setDetailMenu}/>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</ModalContainer>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
export default DetailMenu;
|
||||
@@ -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(
|
||||
<div>
|
||||
<HeadTitle title={"Patients"}/>
|
||||
<Container>
|
||||
<MenuDisplay ItemList={ItemList} user={user} data={patients} loading={loading} error={error} setDetailMenu={setDetailMenu}/>
|
||||
{deleteMenu ? <DeleteMenu deleteMenu={deleteMenu} setDeleteMenu={setDeleteMenu} setDetailMenu={setDetailMenu} link={'patients'} user={user} element={'Ce patient'} /> : null}
|
||||
{detailMenu ? <DetailMenu detail={detailMenu} setDetailMenu={setDetailMenu}/> : null}
|
||||
</Container>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
24
src/components/dashboard/admin/patient/item-list/index.jsx
Normal file
24
src/components/dashboard/admin/patient/item-list/index.jsx
Normal file
@@ -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 (
|
||||
<div className="text-xl bg-cyan-300 p-4 w-full flex flex-row">
|
||||
<div className="w-3/4">
|
||||
<h3 className="text-3xl py-2">{item.first_name} {item.last_name.toUpperCase()} - {item.username}</h3>
|
||||
<p>Genre : {item.gender}, Date de naissance : {date.getDay() > 9 ? date.getDay() : "0"+date.getDay()}/{date.getMonth() > 9 ? date.getMonth() : "0"+date.getMonth()}/{date.getFullYear()}</p>
|
||||
<p>{item.email}, {item.phone}</p>
|
||||
</div>
|
||||
<div className="flex flex-row items-center justify-beetween gap-4">
|
||||
<button className="bg-blue-500 text-white px-4 py-2 rounded-lg" onClick={() => setDetailMenu(item)}>Détails</button>
|
||||
<DeleteButton setDeleteMenu={setDeleteMenu} id={item.id} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ItemList;
|
||||
@@ -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(
|
||||
<div>
|
||||
<div className="">
|
||||
<HeadTitle title={"Utilisateurs"}/>
|
||||
<Container>
|
||||
<MenuDisplay data={users} ItemList={ItemList} user={user} error={error} loading={loading} setDeleteMenu={setDeleteMenu}/>
|
||||
{deleteMenu ? <DeleteMenu deleteMenu={deleteMenu} setDeleteMenu={setDeleteMenu} link={'users'} user={user} element={'Cet utilisateur'} /> : null}
|
||||
</Container>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,20 @@
|
||||
function ItemList({item, setDeleteMenu}) {
|
||||
<div>
|
||||
import DeleteButton from "../../../delete-button";
|
||||
|
||||
function ItemList({ item, setDeleteMenu }) {
|
||||
return (
|
||||
<div className="text-xl bg-cyan-300 p-4 w-full flex flex-row">
|
||||
<div className="w-3/4">
|
||||
<h3 className="text-3xl py-2">{item.first_name} {item.last_name.toUpperCase()} - {item.username}</h3>
|
||||
<p>{item.email} - {item.email_verified ? 'Vérifié' : 'Non vérifié'}</p>
|
||||
<p>{item.phone} - {item.phone_verified ? "Vérifié" : "Non vérifié"}</p>
|
||||
</div>
|
||||
<div className="flex flex-row items-center justify-beetween gap-4">
|
||||
<div className="flex flex-col items-center justify-beetween gap-4">
|
||||
<DeleteButton setDeleteMenu={setDeleteMenu} id={item.id} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ItemList;
|
||||
@@ -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 (
|
||||
<div>
|
||||
<HeadTitle title="Appointment" />
|
||||
<MenuDisplay loading={loading} error={error} data={appointments} ItemList={ItemList} setDeleteMenu={setDeleteMenu}/>
|
||||
<HeadTitle title="Rendez-vous" />
|
||||
<MenuDisplay loading={loading} error={error} data={appointments} ItemList={ItemList} setDeleteMenu={setDeleteMenu} setPrescriptionMenu={setPrescriptionMenu}/>
|
||||
{ deleteMenu ? <DeleteMenu deleteMenu={deleteMenu} setDeleteMenu={setDeleteMenu} user={user} link={"doctors/@me/appointments"} element={"ce rendez-vous"}/> : null }
|
||||
{ prescriptionMenu ? <PrescriptionMenu prescriptionMenu={prescriptionMenu} setPrescriptionMenu={setPrescriptionMenu} user={user}/> : null }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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 (
|
||||
<div className="text-xl bg-cyan-300 p-4 w-full flex flex-row">
|
||||
@@ -10,6 +11,7 @@ function ItemList({item, setDeleteMenu}) {
|
||||
</div>
|
||||
<div className="flex flex-row items-center justify-beetween gap-4">
|
||||
{/* <ModifyButton setModifyMenu={setModifyMenu} item={item} /> */}
|
||||
<PrescriptionButton setPrescriptionMenu={setPrescriptionMenu} item={item} />
|
||||
<DeleteButton setDeleteMenu={setDeleteMenu} id={item.id} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
function PrescriptionButton({setPrescriptionMenu,item}) {
|
||||
return (
|
||||
<button className="bg-blue-500 text-white px-4 py-2 rounded-lg" onClick={() => setPrescriptionMenu(item)}>Prescription</button>
|
||||
);
|
||||
}
|
||||
|
||||
export default PrescriptionButton;
|
||||
@@ -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(
|
||||
<ModalContainer>
|
||||
<form action="" className="flex flex-col gap-10" onSubmit={onSubmit}>
|
||||
<div className="text-center text-2xl">
|
||||
<h2>Ajout/Modification d'une préscription</h2>
|
||||
</div>
|
||||
<div>
|
||||
{loading ? <div className="text-center">Chargement...</div> : null}
|
||||
{error ? <div className="text-red-500 text-center">{error}</div> : null}
|
||||
</div>
|
||||
<div className="flex flex-col gap-4 justify-between items-center" >
|
||||
<label htmlFor="content" className='text-xl'>Contenu</label>
|
||||
<textarea onChange={onChange} value={content} name="content" id="content" cols="75" rows="10" className="border-b-2 border-cyan-800 w-1/2 focus:outline-none">
|
||||
</textarea>
|
||||
</div>
|
||||
<div className="flex flex-row gap-8 justify-center">
|
||||
<BackButton setMenu={setPrescriptionMenu}/>
|
||||
<SubmitButton text="Enregistrer"/>
|
||||
</div>
|
||||
</form>
|
||||
</ModalContainer>
|
||||
);
|
||||
}
|
||||
|
||||
export default PrescriptionMenu;
|
||||
@@ -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
|
||||
];
|
||||
|
||||
|
||||
@@ -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(
|
||||
<div className={className}>
|
||||
@@ -6,7 +6,7 @@ function ListDisplay({data, ItemComponent, height = true, setDeleteMenu = null,
|
||||
{
|
||||
data.map((item,index) =>
|
||||
<li>
|
||||
{<ItemComponent key={index} item={item} setDeleteMenu={setDeleteMenu} setModifyMenu={setModifyMenu} user={user} setDetailMenu={setDetailMenu}/>}
|
||||
{<ItemComponent key={index} item={item} setDeleteMenu={setDeleteMenu} setModifyMenu={setModifyMenu} user={user} setDetailMenu={setDetailMenu} setPrescriptionMenu={setPrescriptionMenu}/>}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
<Container>
|
||||
{ loading ? <Loader color={true}/> : null }
|
||||
{ error ? <p className="text-2xl">{error}</p> : null }
|
||||
{ !error && !loading ? <ListDisplay data={data} ItemComponent={ItemList} setDeleteMenu={setDeleteMenu} setModifyMenu={setModifyMenu} user={user} setDetailMenu={setDetailMenu}/> : null }
|
||||
{ !error && !loading ? <ListDisplay data={data} ItemComponent={ItemList} setDeleteMenu={setDeleteMenu} setModifyMenu={setModifyMenu} user={user} setDetailMenu={setDetailMenu} setPrescriptionMenu={setPrescriptionMenu}/> : null }
|
||||
</Container>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
]
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<div>
|
||||
<div className="flex flex-col gap-10 items-center">
|
||||
<HeadTitle title="Préscription"/>
|
||||
{ loading ? <p>Chargement...</p> : null }
|
||||
{ error ? <p>{error}</p> : null }
|
||||
{ prescription ? <ListDisplay data={prescription} ItemComponent={ItemList}/> : null }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
function ItemList({item}) {
|
||||
const date = new Date(item.date);
|
||||
return(
|
||||
<div className="text-xl bg-cyan-300 p-4 w-full flex flex-row">
|
||||
<div className="w-1/2">
|
||||
<h3 className="text-3xl py-2">{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)}</h3>
|
||||
<p>Dr.{item.first_name} {item.last_name}</p>
|
||||
</div>
|
||||
<div className="w-1/2">
|
||||
<p>{item.content}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default ItemList;
|
||||
@@ -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;
|
||||
Reference in New Issue
Block a user