Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dev + update swagger #24

Merged
merged 4 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
"rxjs": "^7.8.1",
"uuid": "^9.0.1",
"winston": "^3.11.0",
"winston-daily-rotate-file": "^4.7.1"
"winston-daily-rotate-file": "^4.7.1",
"xss": "^1.0.14"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

153 changes: 153 additions & 0 deletions prisma/migrations/20240222142320_new_migration/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
-- CreateEnum
CREATE TYPE "Role" AS ENUM ('PATIENT', 'MEDECIN', 'DERMATOLOGUE', 'ADMIN');

-- CreateEnum
CREATE TYPE "Sexe" AS ENUM ('M', 'F');

-- CreateEnum
CREATE TYPE "statusConsultation" AS ENUM ('WAITING', 'IN_PROGRESS', 'PROCESSED', 'CLOSED', 'CANCELED');

-- CreateEnum
CREATE TYPE "FileType" AS ENUM ('IMAGE', 'FILE');

-- CreateEnum
CREATE TYPE "statusAppointment" AS ENUM ('WAITING', 'ACCEPTED', 'CANCELED', 'REFUSED');

-- CreateTable
CREATE TABLE "User" (
"id" TEXT NOT NULL,
"updatedAt" TIMESTAMP(3) NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"role" "Role" NOT NULL,
"firstName" TEXT NOT NULL,
"lastName" TEXT NOT NULL,
"email" TEXT NOT NULL,
"sexe" TEXT NOT NULL DEFAULT 'M',
"password" TEXT NOT NULL,
"rppsNumber" TEXT,
"address" TEXT,
"city" TEXT,
"zipCode" TEXT,
"secuNumber" TEXT,

CONSTRAINT "User_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Consultation" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"idMedecin" TEXT NOT NULL,
"idPatient" TEXT NOT NULL,
"status" "statusConsultation" NOT NULL DEFAULT 'WAITING',
"criticity" INTEGER NOT NULL DEFAULT 0,
"informations" TEXT NOT NULL DEFAULT '',
"resultat" TEXT NOT NULL DEFAULT '',

CONSTRAINT "Consultation_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "File" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"name" TEXT NOT NULL,
"url" TEXT NOT NULL,
"type" "FileType" NOT NULL,
"size" INTEGER NOT NULL,

CONSTRAINT "File_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Appointment" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"idDermatologue" TEXT NOT NULL,
"idPatient" TEXT NOT NULL,
"date" TIMESTAMP(3) NOT NULL,
"status" "statusAppointment" NOT NULL DEFAULT 'WAITING',
"idConsultation" TEXT NOT NULL,

CONSTRAINT "Appointment_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Conversation" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"idFrom" TEXT NOT NULL,
"idToUser" TEXT NOT NULL,
"idToIa" TEXT NOT NULL,

CONSTRAINT "Conversation_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Message" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"content" TEXT NOT NULL,
"idConversation" TEXT NOT NULL,
"idFrom" TEXT,

CONSTRAINT "Message_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "Ia" (
"id" TEXT NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL,
"model" TEXT NOT NULL,
"parameters" JSONB NOT NULL,

CONSTRAINT "Ia_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "User_email_key" ON "User"("email");

-- CreateIndex
CREATE UNIQUE INDEX "User_rppsNumber_key" ON "User"("rppsNumber");

-- CreateIndex
CREATE UNIQUE INDEX "Appointment_idConsultation_key" ON "Appointment"("idConsultation");

-- AddForeignKey
ALTER TABLE "Consultation" ADD CONSTRAINT "Consultation_idMedecin_fkey" FOREIGN KEY ("idMedecin") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Consultation" ADD CONSTRAINT "Consultation_idPatient_fkey" FOREIGN KEY ("idPatient") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "File" ADD CONSTRAINT "File_id_fkey" FOREIGN KEY ("id") REFERENCES "Consultation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Appointment" ADD CONSTRAINT "Appointment_idDermatologue_fkey" FOREIGN KEY ("idDermatologue") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Appointment" ADD CONSTRAINT "Appointment_idPatient_fkey" FOREIGN KEY ("idPatient") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Appointment" ADD CONSTRAINT "Appointment_idConsultation_fkey" FOREIGN KEY ("idConsultation") REFERENCES "Consultation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Conversation" ADD CONSTRAINT "Conversation_idFrom_fkey" FOREIGN KEY ("idFrom") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Conversation" ADD CONSTRAINT "Conversation_idToUser_fkey" FOREIGN KEY ("idToUser") REFERENCES "User"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Conversation" ADD CONSTRAINT "Conversation_idToIa_fkey" FOREIGN KEY ("idToIa") REFERENCES "Ia"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Message" ADD CONSTRAINT "Message_idConversation_fkey" FOREIGN KEY ("idConversation") REFERENCES "Conversation"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "Message" ADD CONSTRAINT "Message_idFrom_fkey" FOREIGN KEY ("idFrom") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE;
3 changes: 3 additions & 0 deletions prisma/migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "postgresql"
13 changes: 10 additions & 3 deletions src/appointments/appointments.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,43 @@ import {
import { AppointmentsService } from './appointments.service';
import { CreateAppointmentDto } from './dto/create-appointment.dto';
import { UpdateAppointmentDto } from './dto/update-appointment.dto';
import { ApiCreatedResponse, ApiOkResponse, ApiTags } from '@nestjs/swagger';
import { AppointmentEntity } from './entities/appointment.entity';

@Controller('appointments')
@ApiTags('Appointments')
export class AppointmentsController {
constructor(private readonly appointmentsService: AppointmentsService) {}

@Post()
@ApiCreatedResponse({ type: CreateAppointmentDto })
create(@Body() createAppointmentDto: CreateAppointmentDto) {
return this.appointmentsService.create(createAppointmentDto);
}

@Get()
@ApiOkResponse({ isArray: true, type: AppointmentEntity })
findAll() {
return this.appointmentsService.findAll();
}

@Get(':id')
@ApiOkResponse({ type: AppointmentEntity })
findOne(@Param('id') id: string) {
return this.appointmentsService.findOne(+id);
return this.appointmentsService.findOne(id);
}

@Patch(':id')
@ApiCreatedResponse({ type: UpdateAppointmentDto })
update(
@Param('id') id: string,
@Body() updateAppointmentDto: UpdateAppointmentDto,
) {
return this.appointmentsService.update(+id, updateAppointmentDto);
return this.appointmentsService.update(id, updateAppointmentDto);
}

@Delete(':id')
remove(@Param('id') id: string) {
return this.appointmentsService.remove(+id);
return this.appointmentsService.remove(id);
}
}
25 changes: 19 additions & 6 deletions src/appointments/appointments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,28 @@ export class AppointmentsService {
return this.prismaService.appointment.findMany();
}

findOne(id: number) {
return `This action returns a #${id} appointment`;
findOne(id: string) {
return this.prismaService.appointment.findUnique({
where: {
id: id,
},
});
}

update(id: number, updateAppointmentDto: UpdateAppointmentDto) {
return `This action updates a #${id} appointment`;
update(id: string, updateAppointmentDto: UpdateAppointmentDto) {
return this.prismaService.appointment.update({
where: {
id: id,
},
data: updateAppointmentDto as Appointment,
});
}

remove(id: number) {
return `This action removes a #${id} appointment`;
remove(id: string) {
return this.prismaService.appointment.delete({
where: {
id: id,
},
});
}
}
37 changes: 36 additions & 1 deletion src/appointments/dto/create-appointment.dto.ts
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
export class CreateAppointmentDto {}
import { ApiProperty } from '@nestjs/swagger';
import { statusAppointment } from '@prisma/client';
import {
IsDateString,
IsEnum,
IsNotEmpty,
IsOptional,
IsString,
} from 'class-validator';

export class CreateAppointmentDto {
@ApiProperty()
@IsNotEmpty()
@IsString()
idDermatologue: string;

@ApiProperty()
@IsNotEmpty()
@IsString()
idPatient: string;

@ApiProperty()
@IsNotEmpty()
@IsDateString()
date: Date;

@ApiProperty({ enum: statusAppointment, default: statusAppointment.WAITING })
@IsOptional()
@IsEnum(statusAppointment)
status: statusAppointment;

@ApiProperty()
@IsNotEmpty()
@IsString()
idConsultation: string;
}
25 changes: 5 additions & 20 deletions src/dermatologues/dermatologues.controller.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
import {
Controller,
Get,
Post,
Body,
Patch,
Param,
Delete,
} from '@nestjs/common';
import { Controller, Get, Param } from '@nestjs/common';
import { DermatologuesService } from './dermatologues.service';
import { ApiTags } from '@nestjs/swagger';
import { ApiOkResponse, ApiTags } from '@nestjs/swagger';
import { DermatologueEntity } from './entities/dermatologue.entity';

@ApiTags('dermatologues')
@Controller('dermatologues')
export class DermatologuesController {
constructor(private readonly dermatologuesService: DermatologuesService) {}

@Get()
@ApiOkResponse({ type: DermatologueEntity, isArray: true })
findAll() {
return this.dermatologuesService.findAll();
}

@Get(':id')
@ApiOkResponse({ type: DermatologueEntity })
findOne(@Param('id') id: string) {
return this.dermatologuesService.findOne(id);
}

// @Patch(':id')
// update(@Param('id') id: string, @Body() updateDermatologueDto: ) {
// return this.dermatologuesService.update(+id, updateDermatologueDto);
// }

// @Delete(':id')
// remove(@Param('id') id: string) {
// return this.dermatologuesService.remove(+id);
// }
}
4 changes: 2 additions & 2 deletions src/dermatologues/entities/dermatologue.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { ApiProperty } from '@nestjs/swagger';
import { Appointment, User } from '@prisma/client';
import { Exclude } from 'class-transformer';

export class Medecin implements User {
constructor(partial: Partial<Medecin>) {
export class DermatologueEntity implements User {
constructor(partial: Partial<DermatologueEntity>) {
Object.assign(this, partial);
}

Expand Down
Loading
Loading