Initial commit: HealthCarePregnant project documentation and platform
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import {
|
||||
CreateActionInput,
|
||||
DispositionService,
|
||||
} from './disposition.service';
|
||||
import {
|
||||
ClosureOutcome,
|
||||
Disposition,
|
||||
DispositionSourceType,
|
||||
RiskLevel,
|
||||
} from './disposition.types';
|
||||
import { RequireCaps } from '../../common/auth/capabilities.decorator';
|
||||
import { CurrentUser } from '../../common/auth/current-user.decorator';
|
||||
import { RequestUser } from '../../common/auth/request-user';
|
||||
|
||||
@Controller()
|
||||
export class DispositionController {
|
||||
constructor(private readonly disposition: DispositionService) {}
|
||||
|
||||
/** 新建处置单(含一个/一组动作) */
|
||||
@Post('patients/:patientId/dispositions')
|
||||
@RequireCaps('disposition:create')
|
||||
create(
|
||||
@Param('patientId') patientId: string,
|
||||
@Body()
|
||||
body: {
|
||||
caseId: string;
|
||||
sourceType: DispositionSourceType;
|
||||
sourceId?: string;
|
||||
title: string;
|
||||
riskLevelAtCreation: RiskLevel;
|
||||
actions: CreateActionInput[];
|
||||
supersedesId?: string;
|
||||
},
|
||||
@CurrentUser() user?: RequestUser,
|
||||
): Promise<Disposition> {
|
||||
return this.disposition.create({ ...body, patientId }, user?.id ?? 'system');
|
||||
}
|
||||
|
||||
@Get('patients/:patientId/dispositions')
|
||||
@RequireCaps('disposition:read')
|
||||
list(@Param('patientId') patientId: string): Promise<Disposition[]> {
|
||||
return this.disposition.listByPatient(patientId);
|
||||
}
|
||||
|
||||
@Get('dispositions/:id')
|
||||
@RequireCaps('disposition:read')
|
||||
get(@Param('id') id: string): Promise<Disposition> {
|
||||
return this.disposition.getById(id);
|
||||
}
|
||||
|
||||
/** 确认中/高风险处置单(人工兜底) */
|
||||
@Post('dispositions/:id/confirm')
|
||||
@RequireCaps('disposition:confirm')
|
||||
confirm(@Param('id') id: string, @CurrentUser() user?: RequestUser): Promise<Disposition> {
|
||||
return this.disposition.confirm(id, user?.id ?? 'system');
|
||||
}
|
||||
|
||||
/** 执行单个处置动作并回执 */
|
||||
@Post('dispositions/:id/actions/:actionId/execute')
|
||||
@RequireCaps('disposition:execute')
|
||||
execute(
|
||||
@Param('id') id: string,
|
||||
@Param('actionId') actionId: string,
|
||||
@Body() body: { linkedEntityId?: string; resultNote?: string },
|
||||
): Promise<Disposition> {
|
||||
return this.disposition.executeAction(id, actionId, body);
|
||||
}
|
||||
|
||||
/** 闭环处置单(记录达标/未达标/升级) */
|
||||
@Post('dispositions/:id/close')
|
||||
@RequireCaps('disposition:execute')
|
||||
close(
|
||||
@Param('id') id: string,
|
||||
@Body() body: { outcome: ClosureOutcome },
|
||||
): Promise<Disposition> {
|
||||
return this.disposition.close(id, body.outcome);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user