44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { Body, Controller, Post, UseGuards } from '@nestjs/common';
|
|
import { IsOptional, IsString, IsUUID, MinLength } from 'class-validator';
|
|
import { Role } from '@reception/db';
|
|
import { Roles } from '../auth/decorators/roles.decorator';
|
|
import { LogsBiometry } from '../auth/decorators/logs-biometry.decorator';
|
|
import { CurrentUser, type AuthUser } from '../auth/decorators/current-user.decorator';
|
|
import { RolesGuard } from '../auth/guards/roles.guard';
|
|
import { EnrollmentService } from './enrollment.service';
|
|
|
|
class EnrollmentDto {
|
|
@IsUUID()
|
|
trackId!: string;
|
|
|
|
@IsString()
|
|
polimedPatientId!: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
polimedAppointmentId?: string;
|
|
|
|
@IsString()
|
|
@MinLength(1)
|
|
paperConsentRef!: string;
|
|
}
|
|
|
|
@UseGuards(RolesGuard)
|
|
@Controller('enrollment')
|
|
export class EnrollmentController {
|
|
constructor(private readonly enrollment: EnrollmentService) {}
|
|
|
|
@Roles(Role.SENIOR_ADMIN)
|
|
@LogsBiometry('enroll')
|
|
@Post()
|
|
enroll(@Body() dto: EnrollmentDto, @CurrentUser() user: AuthUser) {
|
|
return this.enrollment.enroll({
|
|
trackId: dto.trackId,
|
|
polimedPatientId: dto.polimedPatientId,
|
|
polimedAppointmentId: dto.polimedAppointmentId,
|
|
paperConsentRef: dto.paperConsentRef,
|
|
actorUserId: user.id,
|
|
});
|
|
}
|
|
}
|