improvement: v1 standalone treatment/case creation made possible.
This commit is contained in:
@@ -4,17 +4,30 @@ import {
|
||||
Get,
|
||||
Param,
|
||||
Patch,
|
||||
Post,
|
||||
Put,
|
||||
Query,
|
||||
Req,
|
||||
Res,
|
||||
UploadedFiles,
|
||||
UseGuards,
|
||||
UseInterceptors,
|
||||
} from '@nestjs/common';
|
||||
import { FilesInterceptor } from '@nestjs/platform-express';
|
||||
import { memoryStorage } from 'multer';
|
||||
import type { Response } from 'express';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiBearerAuth, ApiConsumes, 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, UpdateLabCaseImportantDto, UpdateLabCaseExternalCodeDto, AssignLabCaseTaskDto } from './dto/cases.dto';
|
||||
import {
|
||||
ListLabCasesDto,
|
||||
UpdateLabCaseImportantDto,
|
||||
UpdateLabCaseExternalCodeDto,
|
||||
AssignLabCaseTaskDto,
|
||||
CreateLabInternalCaseDto,
|
||||
UpdateLabInternalCaseDto,
|
||||
} from './dto/cases.dto';
|
||||
|
||||
@ApiTags('cases')
|
||||
@ApiBearerAuth('JWT-auth')
|
||||
@@ -30,6 +43,13 @@ export class CasesController {
|
||||
return this.casesService.list(organizationId, req.user.id, query);
|
||||
}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'Create a lab-origin draft case (TAB_CASES_EDIT)' })
|
||||
create(@Body() dto: CreateLabInternalCaseDto, @Req() req) {
|
||||
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
||||
return this.casesService.createInternal(dto, organizationId, req.user.id, req.user.language);
|
||||
}
|
||||
|
||||
@Get('assignable-staff')
|
||||
@ApiOperation({ summary: 'Staff who can be assigned lab tasks' })
|
||||
listAssignableStaff(@Req() req) {
|
||||
@@ -44,6 +64,13 @@ export class CasesController {
|
||||
return this.casesService.listFilterOptions(organizationId, req.user.id);
|
||||
}
|
||||
|
||||
@Get('linked-clinics')
|
||||
@ApiOperation({ summary: 'Active linked clinic organizations for lab-origin cases' })
|
||||
listLinkedClinics(@Req() req) {
|
||||
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
||||
return this.casesService.listLinkedClinics(organizationId, req.user.id);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@ApiOperation({ summary: 'Get one lab case with tasks grouped by tooth' })
|
||||
getOne(@Param('id') id: string, @Req() req) {
|
||||
@@ -51,6 +78,44 @@ export class CasesController {
|
||||
return this.casesService.getOne(id, organizationId, req.user.id, req.user.language);
|
||||
}
|
||||
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'Update a lab-origin draft case and its lines' })
|
||||
update(@Param('id') id: string, @Body() dto: UpdateLabInternalCaseDto, @Req() req) {
|
||||
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
||||
return this.casesService.updateInternal(id, dto, organizationId, req.user.id, req.user.language);
|
||||
}
|
||||
|
||||
@Post(':id/start')
|
||||
@ApiOperation({ summary: 'Start a lab-origin draft (generate tasks, no clinic notify)' })
|
||||
start(@Param('id') id: string, @Req() req) {
|
||||
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
||||
return this.casesService.startInternal(id, organizationId, req.user.id, req.user.language);
|
||||
}
|
||||
|
||||
@Post(':id/lines/:lineClientKey/attachments')
|
||||
@ApiOperation({ summary: 'Upload attachments for a lab-origin draft line' })
|
||||
@ApiConsumes('multipart/form-data')
|
||||
@UseInterceptors(
|
||||
FilesInterceptor('files', 20, {
|
||||
storage: memoryStorage(),
|
||||
}),
|
||||
)
|
||||
uploadAttachments(
|
||||
@Param('id') id: string,
|
||||
@Param('lineClientKey') lineClientKey: string,
|
||||
@UploadedFiles() files: Express.Multer.File[],
|
||||
@Req() req,
|
||||
) {
|
||||
const organizationId = this.casesService.getOrganizationIdFromUser(req.user);
|
||||
return this.casesService.uploadInternalAttachments(
|
||||
id,
|
||||
lineClientKey,
|
||||
files,
|
||||
organizationId,
|
||||
req.user.id,
|
||||
);
|
||||
}
|
||||
|
||||
@Get(':id/attachments/:attachmentId/file')
|
||||
@ApiOperation({ summary: 'Download an attachment shared with this lab case' })
|
||||
async downloadAttachment(
|
||||
|
||||
Reference in New Issue
Block a user