2026-06-28 16:46:42 +03:30
|
|
|
import {
|
|
|
|
|
Body,
|
|
|
|
|
Controller,
|
|
|
|
|
Get,
|
|
|
|
|
Param,
|
|
|
|
|
Patch,
|
|
|
|
|
Query,
|
|
|
|
|
Req,
|
|
|
|
|
UseGuards,
|
|
|
|
|
} from '@nestjs/common';
|
|
|
|
|
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
|
|
|
import { LabOrgGuard } from '../../common/guards/lab-org.guard';
|
|
|
|
|
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
|
|
|
|
|
import { CasesService } from './cases.service';
|
|
|
|
|
import { ListLabCasesDto, UpdateLabCaseTaskDto } from './dto/cases.dto';
|
|
|
|
|
|
|
|
|
|
@ApiTags('cases')
|
|
|
|
|
@ApiBearerAuth('JWT-auth')
|
|
|
|
|
@UseGuards(JwtAuthGuard, LabOrgGuard)
|
|
|
|
|
@Controller('cases')
|
|
|
|
|
export class CasesController {
|
|
|
|
|
constructor(private readonly casesService: CasesService) {}
|
|
|
|
|
|
|
|
|
|
@Get()
|
|
|
|
|
@ApiOperation({ summary: 'List lab cases received by this organization' })
|
|
|
|
|
list(@Query() query: ListLabCasesDto, @Req() req) {
|
|
|
|
|
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
|
|
|
|
return this.casesService.list(organizationId, req.user.id, query);
|
2026-06-28 17:49:40 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get('filter-options')
|
|
|
|
|
@ApiOperation({ summary: 'Clinics and treatment types for inbox filters' })
|
|
|
|
|
listFilterOptions(@Req() req) {
|
|
|
|
|
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
|
|
|
|
return this.casesService.listFilterOptions(organizationId, req.user.id);
|
2026-06-28 16:46:42 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Get(':id')
|
|
|
|
|
@ApiOperation({ summary: 'Get one lab case with tasks grouped by tooth' })
|
|
|
|
|
getOne(@Param('id') id: string, @Req() req) {
|
|
|
|
|
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
2026-07-06 20:40:19 +03:30
|
|
|
return this.casesService.getOne(id, organizationId, req.user.id, req.user.language);
|
2026-06-28 16:46:42 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Patch(':id/tasks/:taskId')
|
2026-07-07 15:31:09 +03:30
|
|
|
@ApiOperation({ summary: 'Toggle task important flag' })
|
2026-06-28 16:46:42 +03:30
|
|
|
updateTask(
|
|
|
|
|
@Param('id') id: string,
|
|
|
|
|
@Param('taskId') taskId: string,
|
|
|
|
|
@Body() dto: UpdateLabCaseTaskDto,
|
|
|
|
|
@Req() req,
|
|
|
|
|
) {
|
|
|
|
|
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
2026-07-06 20:40:19 +03:30
|
|
|
return this.casesService.updateTask(id, taskId, dto, organizationId, req.user.id, req.user.language);
|
2026-06-28 16:46:42 +03:30
|
|
|
}
|
|
|
|
|
}
|