mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-04-12 02:18:18 +00:00
- Replace raw @anthropic-ai/sdk with Vercel AI SDK (generateText, tool, generateObject) - Add provider abstraction (ai-provider.ts) — swap OpenAI/Anthropic via env var - AI chat controller: dynamic KB from platform (clinics, packages, insurance), zero hardcoding - AI enrichment service: use generateObject with Zod schema instead of manual JSON parsing - Worklist: resolve agent name from platform currentUser API instead of JWT decode - Worklist: fix GraphQL field names to match platform remapping (source, status, direction, etc.) - Config: add AI_PROVIDER, AI_MODEL, OPENAI_API_KEY env vars Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { Controller, Get, Headers, HttpException, Logger } from '@nestjs/common';
|
|
import { PlatformGraphqlService } from '../platform/platform-graphql.service';
|
|
import { WorklistService } from './worklist.service';
|
|
|
|
@Controller('api/worklist')
|
|
export class WorklistController {
|
|
private readonly logger = new Logger(WorklistController.name);
|
|
|
|
constructor(
|
|
private readonly worklist: WorklistService,
|
|
private readonly platform: PlatformGraphqlService,
|
|
) {}
|
|
|
|
@Get()
|
|
async getWorklist(@Headers('authorization') authHeader: string) {
|
|
if (!authHeader) {
|
|
throw new HttpException('Authorization required', 401);
|
|
}
|
|
|
|
const agentName = await this.resolveAgentName(authHeader);
|
|
this.logger.log(`Fetching worklist for agent: ${agentName}`);
|
|
|
|
return this.worklist.getWorklist(agentName, authHeader);
|
|
}
|
|
|
|
private async resolveAgentName(authHeader: string): Promise<string> {
|
|
try {
|
|
const data = await this.platform.queryWithAuth<any>(
|
|
`{ currentUser { workspaceMember { name { firstName lastName } } } }`,
|
|
undefined,
|
|
authHeader,
|
|
);
|
|
const name = data.currentUser?.workspaceMember?.name;
|
|
const full = `${name?.firstName ?? ''} ${name?.lastName ?? ''}`.trim();
|
|
if (full) return full;
|
|
} catch (err) {
|
|
this.logger.warn(`Failed to resolve agent name: ${err}`);
|
|
}
|
|
throw new HttpException('Could not determine agent identity', 400);
|
|
}
|
|
}
|