- Admin CMS: announcements, feature flags, email templates, AI prompts, SMTP, model management, reset-to-defaults - Save/resume encounter progress with 7-day auto-expiry and patient labels - Inline searchable load popover (replaces settings-modal redirect) - User memory/template system (physical exam, ROS, encounter format, etc.) - SSHADESS psychosocial screening form (8 domains, listen-in recording) - Well visit note generation with vitals, vaccines, screenings, SSHADESS - Interactive screenings/vaccines status buttons (Done/Refused/Already Given/N/A) - ROS 15-system checklist + PE 17-system checklist in well visit note tab - ICD-10 diagnoses tag picker (28 common pediatric codes + free text) - Simple sick visit tab: chief complaint, inferred ROS (4) + PE (7), diagnoses, generate note - Settings converted from modal to full-page tab - Fix: /api/models moved before authenticated routes (was returning 401 → empty model selector) - Fix: getUserMemoryContext always fetches from API regardless of cache state - Pause/resume recording on all recording tabs - Site-level SMTP config stored in DB; ElevenLabs TTS with browser fallback
52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
// ============================================================
|
|
// CONFIG.JS — DB-backed app config with in-memory cache
|
|
// Falls back to provided defaults if DB is unavailable
|
|
// ============================================================
|
|
|
|
const db = require('../db/database');
|
|
|
|
const _cache = {};
|
|
const CACHE_TTL = 2 * 60 * 1000; // 2 minutes
|
|
|
|
async function get(key, defaultVal) {
|
|
const now = Date.now();
|
|
if (_cache[key] && (now - _cache[key].ts) < CACHE_TTL) {
|
|
return _cache[key].value;
|
|
}
|
|
try {
|
|
const val = await db.getSetting(key);
|
|
const result = (val !== null && val !== undefined) ? val : (defaultVal !== undefined ? defaultVal : null);
|
|
_cache[key] = { value: result, ts: now };
|
|
return result;
|
|
} catch (e) {
|
|
return defaultVal !== undefined ? defaultVal : null;
|
|
}
|
|
}
|
|
|
|
async function set(key, value) {
|
|
await db.setSetting(key, String(value));
|
|
_cache[key] = { value: String(value), ts: Date.now() };
|
|
}
|
|
|
|
function invalidate(key) {
|
|
if (key) {
|
|
delete _cache[key];
|
|
} else {
|
|
Object.keys(_cache).forEach(k => delete _cache[k]);
|
|
}
|
|
}
|
|
|
|
async function getByPrefix(prefix) {
|
|
try {
|
|
const rows = await db.all(
|
|
"SELECT key, value, updated_at FROM app_settings WHERE key LIKE $1 ORDER BY key",
|
|
[prefix + '%']
|
|
);
|
|
rows.forEach(r => { _cache[r.key] = { value: r.value, ts: Date.now() }; });
|
|
return rows;
|
|
} catch (e) {
|
|
return [];
|
|
}
|
|
}
|
|
|
|
module.exports = { get, set, invalidate, getByPrefix };
|