From ccab4d10cc9b8826a830a9d4afb1afa41c110006 Mon Sep 17 00:00:00 2001 From: AC1910 Date: Thu, 5 Feb 2026 01:30:30 +0100 Subject: [PATCH] =?UTF-8?q?Cr=C3=A9ation=20des=20mod=C3=A8les=20et=20recon?= =?UTF-8?q?figuration=20BD(Changement=20de=20quuelques=20minuscules=20en?= =?UTF-8?q?=20majuscules)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/database/schemas.ql | 11 ----------- backend/database/schemas.sql | 11 +++++++++++ backend/modeles/Admin.model.js | 11 +++++++++++ backend/modeles/Appointment.model.js | 15 +++++++++++++++ backend/modeles/Docteur.model.js | 13 +++++++++++++ backend/modeles/Notification.model.js | 16 ++++++++++++++++ backend/modeles/User.model.js | 13 +++++++++++++ package-lock.json | 3 ++- package.json | 12 +++++++++++- 9 files changed, 92 insertions(+), 13 deletions(-) delete mode 100644 backend/database/schemas.ql create mode 100644 backend/database/schemas.sql create mode 100644 backend/modeles/Admin.model.js create mode 100644 backend/modeles/Appointment.model.js create mode 100644 backend/modeles/Docteur.model.js create mode 100644 backend/modeles/Notification.model.js create mode 100644 backend/modeles/User.model.js diff --git a/backend/database/schemas.ql b/backend/database/schemas.ql deleted file mode 100644 index d873326..0000000 --- a/backend/database/schemas.ql +++ /dev/null @@ -1,11 +0,0 @@ -/*==================HEALTHCONNECT-SCHEMA DE BASE DE DONNEES==========*/ -/*==================Table Users==============*/ -CREATE TABLE users(id SERIAL PRIMARY KEY,nom VARCHAR(100) NOT NULL,email VARCHAR(100) UNIQUE NOT NULL, Motdepasse VARCHAR(255)NOT NULL,role VARCHAR(20) NOT NULL/*Patient,Docteur,Admin*/); -/*==================Table Docteur=============*/ -CREATE TABLE docteur(id SERIAL PRIMARY KEY,user_id INT UNIQUE REFERENCES users(id) ON DELETE CASCADE, specialite VARCHAR(100) NOT NULL,aviabilite VARCHAR(100)); -/*==================Table Rendez-vous=============*/ -CREATE TABLE appointments(id SERIAL PRIMARY KEY,patient_id INT REFERENCES users(id) ON DELETE CASCADE,docteur_id INT REFERENCES docteur(id) ON DELETE CASCADE, date TIMESTAMP NOT NULL, status VARCHAR(20) DEFAULT 'En attente'); -/*==================Table NOTIFICATIONS=============*/ -CREATE TABLE notifications(id SERIAL PRIMARY KEY, user_id INT REFERENCES users(id) ON DELETE CASCADE, type VARCHAR(20),message TEXT, sent_at TIMESTAMP,status VARCHAR(20)); -/*==================Table Admin=============*/ -CREATE TABLE admin(id SERIAL PRIMARY KEY, user_id INT UNIQUE REFERENCES user(id) ON DELETE CASCADE); diff --git a/backend/database/schemas.sql b/backend/database/schemas.sql new file mode 100644 index 0000000..0ce7759 --- /dev/null +++ b/backend/database/schemas.sql @@ -0,0 +1,11 @@ +/*==================HEALTHCONNECT-SCHEMA DE BASE DE DONNEES==========*/ +/*==================Table Users==============*/ +CREATE TABLE User(id SERIAL PRIMARY KEY,nom VARCHAR(100) NOT NULL,email VARCHAR(100) UNIQUE NOT NULL, motdepasse VARCHAR(255)NOT NULL,role VARCHAR(20) NOT NULL/*Patient,Docteur,Admin*/); +/*==================Table Docteur=============*/ +CREATE TABLE Docteur(id SERIAL PRIMARY KEY,User_id INT UNIQUE REFERENCES Users(id) ON DELETE CASCADE, specialite VARCHAR(100) NOT NULL,avaliability VARCHAR(100)); +/*==================Table Rendez-vous=============*/ +CREATE TABLE Appointment(id SERIAL PRIMARY KEY,patient_id INT REFERENCES Users(id) ON DELETE CASCADE,docteur_id INT REFERENCES docteur(id) ON DELETE CASCADE, date TIMESTAMP NOT NULL, status VARCHAR(20) DEFAULT 'En attente'); +/*==================Table NOTIFICATIONS=============*/ +CREATE TABLE Notification(id SERIAL PRIMARY KEY, User_id INT REFERENCES Users(id) ON DELETE CASCADE, type VARCHAR(20),message TEXT, sent_at TIMESTAMP,status VARCHAR(20)); +/*==================Table Admin=============*/ +CREATE TABLE Admin(id SERIAL PRIMARY KEY, User_id INT UNIQUE REFERENCES User(id) ON DELETE CASCADE); diff --git a/backend/modeles/Admin.model.js b/backend/modeles/Admin.model.js new file mode 100644 index 0000000..6b6a84f --- /dev/null +++ b/backend/modeles/Admin.model.js @@ -0,0 +1,11 @@ +const { DataTypes } = require("pool"); +const pool = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\config\db.js"); +const User = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\modeles\User.model.js"); +const Admin = pool.define("Admin", +{ + id: {type: DataTypes.INTEGER,primaryKey: true,autoIncrement: true}, +}, +{tableName: "Admin",timestamps: false} +); +Admin.belongsTo(User, { foreignKey: "User_id"}); +module.exports = Admin; \ No newline at end of file diff --git a/backend/modeles/Appointment.model.js b/backend/modeles/Appointment.model.js new file mode 100644 index 0000000..a9b1bcc --- /dev/null +++ b/backend/modeles/Appointment.model.js @@ -0,0 +1,15 @@ +const { DataTypes } = require("pool"); +const pool = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\config\db.js"); +const User = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\modeles\User\User.model.js"); +const Docteur = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\modeles\Docteur.model.js"); +const Appointment = pool.define("Appointment", +{ + id: {type: DataTypes.INTEGER,primaryKey: true,autoIncrement: true}, + date:{ type: DataTypes.DATE,allowNull: false}, + status: {type: DataTypes.STRING(20),defaultvalue: "En attente"} +}, +{tableName: "Appointment",timestamps: false} +); +Appointment.belongsTo(User, { foreignKey:"patient_id"}); +Appointment.belongsTo(Docteur, { foreignKey:"docteur_id"}); +module.exports = Appointment; \ No newline at end of file diff --git a/backend/modeles/Docteur.model.js b/backend/modeles/Docteur.model.js new file mode 100644 index 0000000..df82d2e --- /dev/null +++ b/backend/modeles/Docteur.model.js @@ -0,0 +1,13 @@ +const { DataTypes } = require("pool"); +const pool = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\config\db.js"); +const User = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\modeles\User.model.js"); +const Docteur = pool.define("Docteur", +{ + id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, + specialite: { type: DataType.STRING(100), allowNull: false }, + avaliability: { type: DataTypes.STRING(100)} +}, +{tableName: "Docteur",timestamps: false} +); +Doctor.belongsTo(User, { foreignkey: "User_id"}); +module.exports = Docteur; \ No newline at end of file diff --git a/backend/modeles/Notification.model.js b/backend/modeles/Notification.model.js new file mode 100644 index 0000000..104d428 --- /dev/null +++ b/backend/modeles/Notification.model.js @@ -0,0 +1,16 @@ +const { DataTypes } = require("pool"); +const pool = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\config\db.js"); +const User = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\modeles\User.model.js"); +const Notification = pool.define(" Notification", +{ + id: {type: DataTypes.INTEGER,primaryKey: true,autoIncrement: true}, + type: {type: DataTypes.STRING(20)}, + message:{ type: DataTypes.TEXT}, + sent_at:{type: DataTypes.DATE}, + status: {type: DataTypes.STRING(20)} +}, +{tableName: "Notification",timestamps: false} +); +Notification.belongsTo(User, { foreignKey: "User_id"}); +User.hasMany(Notification,{ foreignKey:"User_id"}); +module.exports = Notification; \ No newline at end of file diff --git a/backend/modeles/User.model.js b/backend/modeles/User.model.js new file mode 100644 index 0000000..f278ef7 --- /dev/null +++ b/backend/modeles/User.model.js @@ -0,0 +1,13 @@ +const { DataTypes } = require("pool"); +const pool = require ("C:\Users\User\Documents\GitHub\HealthConnect\backend\config\db.js"); +const User = pool.define("User", +{ +id: {type: DataTypes.INTEGER,primaryKey: true,autoIncrement: true }, +nom: {type: DataTypes.STRING(100), allowNull: false }, +email: {type: DataTypes.STRING(100), allowNull: false, unique: true }, +motdepasse: {type: DataTypes.STRING(255), allowNull: false }, +role: {type: DataTypes.STRING(20), allowNull: false } +}, + {tableName: "User",timestamps: false} +); +module.exports = User; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 967eb29..2d3d2c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,8 @@ "dotenv": "^17.2.3", "express": "^5.2.1", "pg": "^8.18.0" - } + }, + "devDependencies": {} }, "node_modules/accepts": { "version": "2.0.0", diff --git a/package.json b/package.json index 2469e51..da8a765 100644 --- a/package.json +++ b/package.json @@ -13,5 +13,15 @@ "dotenv": "^17.2.3", "express": "^5.2.1", "pg": "^8.18.0" - } + }, + "devDependencies": {}, + "repository": { + "type": "git", + "url": "git+https://github.com/IRAGAME/HealthConnect.git" + }, + "keywords": [], + "bugs": { + "url": "https://github.com/IRAGAME/HealthConnect/issues" + }, + "homepage": "https://github.com/IRAGAME/HealthConnect#readme" }