| name | openevidence-core-workflow-b |
| description | Execute OpenEvidence DeepConsult workflow for comprehensive medical research.
Use when implementing deep research synthesis, complex clinical questions,
or when physicians need extensive literature review.
Trigger with phrases like "openevidence deepconsult", "deep research",
"comprehensive evidence", "literature synthesis".
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Grep |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
OpenEvidence Core Workflow B: DeepConsult
Overview
DeepConsult is OpenEvidence's advanced research synthesis feature. It uses reasoning models to autonomously analyze and cross-reference hundreds of peer-reviewed medical studies, producing comprehensive research reports that would otherwise take months of human effort.
Prerequisites
- Completed
openevidence-install-auth setup
- Understanding of clinical research methodologies
- Valid API credentials with DeepConsult access
Key Differences from Clinical Query
| Feature | Clinical Query | DeepConsult |
|---|
| Response time | 5-10 seconds | 2-5 minutes |
| Compute cost | 1x | 100x+ |
| Studies analyzed | 5-10 | Hundreds |
| Use case | Point-of-care | Research synthesis |
| Output | Quick answer | Comprehensive report |
Instructions
Step 1: Initiate DeepConsult Request
import { OpenEvidenceClient } from '@openevidence/sdk';
interface DeepConsultRequest {
question: string;
specialty: string;
researchFocus?: 'treatment' | 'diagnosis' | 'prognosis' | 'epidemiology';
timeframe?: {
startYear?: number;
endYear?: number;
};
preferredSources?: string[];
excludeSources?: string[];
}
interface DeepConsultResponse {
id: string;
status: 'pending' | 'processing' | 'completed' | 'failed';
progress?: number;
report?: DeepConsultReport;
estimatedCompletionTime?: number;
}
interface DeepConsultReport {
executiveSummary: string;
detailedFindings: Section[];
methodology: string;
studiesAnalyzed: number;
citations: [];
: [];
: [];
: ;
}
{
: ;
: ;
: [];
}
{
: ;
: ;
: [];
: ;
?: ;
?: ;
?: ;
?: ;
}
Step 2: Implement Async DeepConsult Service
const client = new OpenEvidenceClient({
apiKey: process.env.OPENEVIDENCE_API_KEY,
orgId: process.env.OPENEVIDENCE_ORG_ID,
timeout: 300000,
});
export async function initiateDeepConsult(
request: DeepConsultRequest
): Promise<string> {
const response = await client.deepConsult.create({
question: request.question,
context: {
specialty: request.specialty,
researchFocus: request.researchFocus || 'treatment',
timeframe: request.timeframe,
},
options: {
preferredSources: request.preferredSources,
excludeSources: request.excludeSources,
maxDepth: 'comprehensive',
},
});
return response.consultId;
}
export async function (): <> {
status = client..(consultId);
{
: consultId,
: status.,
: status.,
: status. === ? status. : ,
: status.,
};
}
(): <> {
pollInterval = ;
maxWait = ;
startTime = .();
(.() - startTime < maxWait) {
status = (consultId);
(status. && onProgress) {
(status.);
}
(status. === && status.) {
status.;
}
(status. === ) {
();
}
( (r, pollInterval));
}
();
}
Step 3: Webhook-Based Completion Handler
import { Request, Response } from 'express';
import { verifyWebhookSignature } from '../openevidence/security';
interface DeepConsultWebhookPayload {
event: 'deepconsult.completed' | 'deepconsult.failed';
consultId: string;
report?: DeepConsultReport;
error?: string;
timestamp: string;
}
export async function handleDeepConsultWebhook(
req: Request,
res: Response
): Promise<void> {
const signature = req.headers['x-openevidence-signature'] as string;
if (!verifyWebhookSignature(req.body, signature)) {
res.status(401).json({ error: 'Invalid signature' });
return;
}
const payload: DeepConsultWebhookPayload = req.;
(payload.) {
:
(payload., payload.!);
;
:
(payload., payload.!);
;
}
res.().({ : });
}
(): <> {
db..({
consultId,
report,
: (),
});
notificationService.({
: ,
consultId,
: report..(, ),
});
}
(): <> {
db..(consultId, {
: ,
error,
});
alertService.({
: ,
: ,
});
}
Step 4: Format Report for Clinical Use
export function formatDeepConsultReport(
report: DeepConsultReport
): FormattedReport {
return {
title: 'OpenEvidence DeepConsult Research Synthesis',
generatedAt: report.generatedAt,
summary: {
text: report.executiveSummary,
studiesReviewed: report.studiesAnalyzed,
evidenceStrength: calculateOverallEvidenceStrength(report.citations),
},
findings: report.detailedFindings.map(section => ({
heading: section.title,
content: section.content,
supportingEvidence: section.citations.length,
})),
clinicalImplications: report.clinicalImplications,
methodology: report.methodology,
limitations: report.limitations,
references: report.citations.map( ({
: i + ,
: (c),
: c.,
: c.,
})),
: ,
};
}
(): {
highLevel = citations.(
c. === || c. ===
).;
ratio = highLevel / citations.;
(ratio > ) ;
(ratio > ) ;
;
}
(): {
authors = c.. >
?
: c..();
;
}
Output
- Comprehensive research report with executive summary
- Hundreds of peer-reviewed studies analyzed
- Evidence-graded citations with study details
- Clinical implications and limitations
Error Handling
| Error | Cause | Solution |
|---|
| Timeout | Extremely complex question | Use webhook for completion notification |
| Insufficient sources | Very narrow topic | Broaden search criteria or timeframe |
| Rate limit | Too many concurrent consults | Queue requests, process sequentially |
| Report incomplete | Processing interrupted | Retry with same consultId |
Cost Considerations
- DeepConsult uses 100x+ compute vs standard queries
- Use for research, not point-of-care
- Implement quotas per user/team
- Cache reports for identical questions
Examples
Research Use Case
async function researchEmergingTreatment() {
const consultId = await initiateDeepConsult({
question: 'What are the latest advances in CAR-T therapy for relapsed B-cell lymphoma?',
specialty: 'oncology',
researchFocus: 'treatment',
timeframe: { startYear: 2022, endYear: 2025 },
preferredSources: ['NEJM', 'JCO', 'Blood', 'Lancet Oncology'],
});
console.log(`DeepConsult initiated: ${consultId}`);
console.log('Report will be ready in approximately 2-5 minutes...');
const report = await waitForDeepConsult(consultId, (progress) => {
console.log(`Progress: ${progress}%`);
});
const formatted = formatDeepConsultReport(report);
return formatted;
}
Resources
Next Steps
For error handling patterns, see openevidence-common-errors.