mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
feat: rules engine — json-rules-engine integration with worklist scoring
- Self-contained NestJS module: types, storage (Redis+JSON), fact providers, action handlers - PriorityConfig CRUD (slider values for task weights, campaign weights, source weights) - Score action handler with SLA multiplier + campaign multiplier formula - Worklist consumer: scores and ranks items before returning - Hospital starter template (7 rules) - REST API: /api/rules/* (CRUD, priority-config, evaluate, templates) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
25
src/rules-engine/consumers/worklist.consumer.ts
Normal file
25
src/rules-engine/consumers/worklist.consumer.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// src/rules-engine/consumers/worklist.consumer.ts
|
||||
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { RulesEngineService } from '../rules-engine.service';
|
||||
import { RulesStorageService } from '../rules-storage.service';
|
||||
|
||||
@Injectable()
|
||||
export class WorklistConsumer {
|
||||
private readonly logger = new Logger(WorklistConsumer.name);
|
||||
|
||||
constructor(
|
||||
private readonly engine: RulesEngineService,
|
||||
private readonly storage: RulesStorageService,
|
||||
) {}
|
||||
|
||||
async scoreAndRank(worklistItems: any[]): Promise<any[]> {
|
||||
const rules = await this.storage.getByTrigger('on_request', 'worklist');
|
||||
if (rules.length === 0) {
|
||||
this.logger.debug('No scoring rules configured — returning unsorted');
|
||||
return worklistItems;
|
||||
}
|
||||
this.logger.debug(`Scoring ${worklistItems.length} items with ${rules.length} rules`);
|
||||
return this.engine.scoreWorklist(worklistItems);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user