diff --git a/src/appointments/appointments.controller.ts b/src/appointments/appointments.controller.ts index 86733da..789d7a6 100644 --- a/src/appointments/appointments.controller.ts +++ b/src/appointments/appointments.controller.ts @@ -10,29 +10,34 @@ import { import { AppointmentsService } from './appointments.service'; import { CreateAppointmentDto } from './dto/create-appointment.dto'; import { UpdateAppointmentDto } from './dto/update-appointment.dto'; -import { ApiTags } from '@nestjs/swagger'; +import { ApiCreatedResponse, ApiOkResponse, ApiTags } from '@nestjs/swagger'; +import { AppointmentEntity } from './entities/appointment.entity'; @Controller('appointments') -@ApiTags('patients') +@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); } @Patch(':id') + @ApiCreatedResponse({ type: UpdateAppointmentDto }) update( @Param('id') id: string, @Body() updateAppointmentDto: UpdateAppointmentDto, diff --git a/src/patients/dto/create-patient.dto.ts b/src/patients/dto/create-patient.dto.ts index f63454c..1c057fc 100644 --- a/src/patients/dto/create-patient.dto.ts +++ b/src/patients/dto/create-patient.dto.ts @@ -1 +1,64 @@ -export class CreatePatientDto {} +import { ApiProperty } from '@nestjs/swagger'; +import { Role } from '@prisma/client'; +import { + IsEnum, + IsNotEmpty, + IsOptional, + IsString, + MinLength, +} from 'class-validator'; + +export class CreatePatientDto { + @IsNotEmpty() + @IsString() + @ApiProperty() + firstName: string; + + @IsNotEmpty() + @IsString() + @ApiProperty() + lastName: string; + + @IsOptional() + @IsEnum(Role) + @ApiProperty({ + enum: Role, + default: Role.PATIENT, + }) + role: Role; + + @IsString() + @IsNotEmpty() + @ApiProperty() + email: string; + + @IsString() + @IsNotEmpty() + @ApiProperty({ default: 'M' }) + sexe: string; + + @IsString() + @IsNotEmpty() + @MinLength(6) + @ApiProperty() + password: string; + + @ApiProperty({ required: false }) + @IsOptional() + @IsString() + address?: string; + + @ApiProperty({ required: false }) + @IsOptional() + @IsString() + city?: string; + + @ApiProperty({ required: false }) + @IsOptional() + @IsString() + zipCode?: string; + + @ApiProperty({ required: true }) + @IsString() + secuNumber: string; +} diff --git a/src/patients/patients.controller.ts b/src/patients/patients.controller.ts index 6408f5b..5c58ca5 100644 --- a/src/patients/patients.controller.ts +++ b/src/patients/patients.controller.ts @@ -15,6 +15,7 @@ import { User } from '@prisma/client'; import { RolesGuard } from 'src/auth/roles.guard'; import { HasRole } from 'src/auth/has-role.decorator'; import { ConsultationEntity } from 'src/consultations/entities/consultation.entity'; +import { PatientEntity } from './entities/patient.entity'; @Controller('patients') @ApiTags('patients') @@ -25,11 +26,13 @@ export class PatientsController { ) {} @Get() + @ApiOkResponse({ type: PatientEntity, isArray: true }) findAll() { return this.patientsService.findAll(); } @Get(':id') + @ApiOkResponse({ type: PatientEntity }) findOne(@Param('id') id: string) { return this.patientsService.findOne(id); } @@ -37,6 +40,7 @@ export class PatientsController { @ApiBearerAuth() @HasRole('PATIENT', 'ADMIN') @UseGuards(JwtAuthGuard, RolesGuard) + @ApiOkResponse({ type: ConsultationEntity, isArray: true }) @Get(':id/consultations') getConsultationsByPatientId(@Param('id') id: string) { return this.consultationService.getConsultationsByPatientId(id);