mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-05-18 20:08:19 +00:00
Redis-cached (5min TTL) lookups via /api/masterdata/departments, /api/masterdata/doctors, /api/masterdata/clinics. Warms cache on startup. Frontend dropdowns use these instead of hardcoded lists. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import { Controller, Get, Query, Logger } from '@nestjs/common';
|
||
import { MasterdataService } from './masterdata.service';
|
||
|
||
@Controller('api/masterdata')
|
||
export class MasterdataController {
|
||
private readonly logger = new Logger(MasterdataController.name);
|
||
|
||
constructor(private masterdata: MasterdataService) {}
|
||
|
||
@Get('departments')
|
||
async departments() {
|
||
return this.masterdata.getDepartments();
|
||
}
|
||
|
||
@Get('doctors')
|
||
async doctors() {
|
||
return this.masterdata.getDoctors();
|
||
}
|
||
|
||
@Get('clinics')
|
||
async clinics() {
|
||
return this.masterdata.getClinics();
|
||
}
|
||
|
||
// Available time slots for a doctor on a given date.
|
||
// Computed from DoctorVisitSlot entities (doctor × clinic × dayOfWeek).
|
||
// Returns 30-min slots within the doctor's visiting window for that day.
|
||
//
|
||
// GET /api/masterdata/slots?doctorId=xxx&date=2026-04-15
|
||
@Get('slots')
|
||
async slots(
|
||
@Query('doctorId') doctorId: string,
|
||
@Query('date') date: string,
|
||
) {
|
||
if (!doctorId || !date) return [];
|
||
return this.masterdata.getAvailableSlots(doctorId, date);
|
||
}
|
||
|
||
// Force cache refresh (admin use)
|
||
@Get('refresh')
|
||
async refresh() {
|
||
await this.masterdata.invalidateAll();
|
||
return { refreshed: true };
|
||
}
|
||
}
|