Skip to content
openevidence-reference-architecture logo

OpenEvidence Reference Architecture

openevidence-reference-architecture

Reference Architecture for OpenEvidence.

SKILL.md

Full skill instructions

OpenEvidence Reference Architecture

Overview

Production architecture for clinical decision support integrations with OpenEvidence. Designed for healthcare platforms needing evidence-based query processing, citation-backed clinical answers, and full audit logging for regulatory compliance. Key design drivers: HIPAA-compliant data handling, deterministic citation pipelines for clinical accuracy, query audit trails for malpractice risk mitigation, and sub-second response times for point-of-care workflows where clinicians need answers during patient encounters.

Architecture Diagram

Clinician UI ──→ API Gateway (auth + HIPAA) ──→ Query Service ──→ OpenEvidence API
                        ↓                            ↓             /​query
                   Audit Logger ──→ Audit DB    Cache (Redis)      /​citations
                        ↓                            ↓
                   Analytics ──→ Usage Dashboard  Citation Store ──→ Evidence DB

Service Layer

class ClinicalQueryService {
  constructor(private oe: OpenEvidenceClient, private cache: CacheLayer, private audit: AuditLogger) {}

  async queryEvidence(query: ClinicalQuery): Promise<EvidenceResponse> {
    await this.audit.log({ type: 'query_submitted', clinicianId: query.clinicianId, queryText: query.text, timestamp: new Date() });
    const cacheKey = `evidence:${this.hashQuery(query.text)}`;
    const cached = await this.cache.get(cacheKey);
    if (cached) { await this.audit.log({ type: 'cache_hit', cacheKey }); return cached; }
    const response = await this.oe.query(query.text, { specialty: query.specialty });
    await this.storeCitations(response.citations);
    await this.cache.set(cacheKey, response, CACHE_CONFIG.evidence.ttl);
    await this.audit.log({ type: 'query_completed', citationCount: response.citations.length });
    return response;
  }

  async getCitationChain(citationId: string): Promise<Citation[]> {
    return this.evidenceDb.getCitationWithReferences(citationId);
  }
}

Caching Strategy

const CACHE_CONFIG = {
  evidence:   { ttl: 86400, prefix: 'evidence' },  // 24 hr — clinical evidence changes slowly
  citations:  { ttl: 604800, prefix: 'cite' },     // 7 days — published citations are stable
  queryHist:  { ttl: 3600, prefix: 'qhist' },      // 1 hr — recent query dedup for same clinician
  guidelines: { ttl: 43200, prefix: 'guide' },      // 12 hr — clinical guidelines update infrequently
  audit:      { ttl: 0, prefix: 'audit' },          // never cached — every audit entry must persist
};
// New guideline publication events invalidate evidence cache for affected specialties

Event Pipeline

class ClinicalEventPipeline {
  private queue = new Bull('clinical-events', { redis: process.env.REDIS_URL });

  async onQueryCompleted(event: QueryCompletedEvent): Promise<void> {
    await this.queue.add('process', event, { attempts: 5, backoff: { type: 'exponential', delay: 2000 } });
  }

  async processQueryEvent(event: QueryCompletedEvent): Promise<void> {
    await this.updateUsageAnalytics(event.clinicianId, event.specialty);
    if (event.feedbackScore !== undefined) await this.logFeedback(event);
    await this.checkGuidelineAlignment(event);  // Flag if answer diverges from current guidelines
  }
}

Data Model

interface ClinicalQuery    { clinicianId: string; text: string; specialty: string; patientContext?: string; urgency: 'routine' | 'urgent'; }
interface EvidenceResponse { answer: string; confidence: number; citations: Citation[]; specialty: string; responseTimeMs: number; }
interface Citation         { id: string; title: string; journal: string; year: number; doi: string; relevanceScore: number; evidenceLevel: 'I' | 'II' | 'III' | 'IV' | 'V'; }
interface AuditEntry       { id: string; type: string; clinicianId: string; timestamp: Date; queryText?: string; citationCount?: number; ipAddress: string; }

Scaling Considerations

  • Separate audit write path from query path — audit logging must never slow clinical responses
  • Cache evidence responses aggressively — same clinical questions recur across clinicians
  • Partition audit DB by month for compliance retention windows and query performance
  • Use read replicas for analytics dashboard; primary DB reserved for audit writes
  • Rate-limit per clinician to prevent abuse while ensuring genuine clinical queries are never blocked

Error Handling

ComponentFailure ModeRecovery
Evidence queryOpenEvidence API timeoutServe cached response if available, degrade to "consult specialist" message
Audit loggingAudit DB write failureBuffer to local WAL, retry with dead-letter queue — never drop audit entries
Citation retrievalDOI resolution failureReturn citation metadata without full text link, flag for manual review
Cache layerRedis connection lostBypass cache, query API directly, alert ops for cache restoration
HIPAA complianceUnauthorized access attemptImmediate block, audit log, alert security team, preserve evidence

Resources

Next Steps

See openevidence-deploy-integration.

More skills from jeremylongshore

openrouter-compliance-review logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-compliance-review

Review OpenRouter integration for regulatory compliance (SOC2, GDPR,

2.8K 0
View
maintainx-data-handling logo
jeremylongshore/claude-code-plugins-plus-skills

maintainx-data-handling

Data synchronization, ETL patterns, and data management for MaintainX.

2.8K 0
View
groq-core-workflow-a logo
jeremylongshore/claude-code-plugins-plus-skills

groq-core-workflow-a

Execute Groq primary workflow: chat completions with tool use and JSON

2.8K 0
View
validating-csrf-protection logo
jeremylongshore/claude-code-plugins-plus-skills

validating-csrf-protection

Validate CSRF protection implementations for security gaps. Use when

2.8K 0
View
api-contract logo
jeremylongshore/claude-code-plugins-plus-skills

api-contract

Configure this skill should be used when the user asks about "API contract",

2.8K 0
View
ideogram-incident-runbook logo
jeremylongshore/claude-code-plugins-plus-skills

ideogram-incident-runbook

Execute Ideogram incident response with triage, mitigation, and postmortem.

2.8K 0
View
gamma-sdk-patterns logo
jeremylongshore/claude-code-plugins-plus-skills

gamma-sdk-patterns

Reusable patterns for the Gamma REST API (no SDK exists).

2.8K 0
View
deepgram-sdk-patterns logo
jeremylongshore/claude-code-plugins-plus-skills

deepgram-sdk-patterns

Apply production-ready Deepgram SDK patterns for TypeScript and Python.

2.8K 0
View
openrouter-upgrade-migration logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-upgrade-migration

Migrate to OpenRouter from direct provider APIs or upgrade between SDK/model

2.8K 0
View
openrouter-common-errors logo
jeremylongshore/claude-code-plugins-plus-skills

openrouter-common-errors

Diagnose and fix common OpenRouter API errors. Use when encountering

2.8K 0
View
linear-cost-tuning logo
jeremylongshore/claude-code-plugins-plus-skills

linear-cost-tuning

Optimize Linear API usage, reduce unnecessary calls, and maximize

2.8K 0
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View