| name | openevidence-upgrade-migration |
| description | Upgrade OpenEvidence SDK versions and migrate between API versions.
Use when upgrading SDK, migrating to new API version,
or planning OpenEvidence version updates.
Trigger with phrases like "openevidence upgrade", "openevidence migrate",
"update openevidence sdk", "openevidence new version", "openevidence breaking changes".
|
| allowed-tools | Read, Write, Edit, Bash(npm:*), Bash(pip:*), Grep |
| version | 1.0.0 |
| license | MIT |
| author | Jeremy Longshore <jeremy@intentsolutions.io> |
OpenEvidence Upgrade & Migration
Overview
Safely upgrade OpenEvidence SDK versions and migrate between API versions with minimal disruption to clinical workflows.
Prerequisites
- Current OpenEvidence integration running
- Access to staging environment
- Changelog for target version
- Test suite passing
Version Compatibility Matrix
| SDK Version | API Version | Node.js | Python | Status |
|---|
| 3.x | v3 | 20+ | 3.11+ | Current |
| 2.x | v2 | 18+ | 3.10+ | Maintained |
| 1.x | v1 | 16+ | 3.8+ | Deprecated |
Instructions
Step 1: Review Changelog and Breaking Changes
npm list @openevidence/sdk
pip show openevidence
Step 2: Update Dependencies
npm install @openevidence/sdk@3.0.0
npm install @openevidence/sdk@latest
pip install openevidence==3.0.0
pip install --upgrade openevidence
Step 3: Common Migration Patterns
SDK v2 to v3 Migration
Client Initialization Changes:
import { OpenEvidence } from '@openevidence/sdk';
const client = new OpenEvidence(process.env.OPENEVIDENCE_API_KEY);
import { OpenEvidenceClient } from '@openevidence/sdk';
const client = new OpenEvidenceClient({
apiKey: process.env.OPENEVIDENCE_API_KEY,
orgId: process.env.OPENEVIDENCE_ORG_ID,
});
Query Method Changes:
const response = await client.query('What is the treatment for...');
const response = await client.query({
question: 'What is the treatment for...',
context: {
specialty: 'internal-medicine',
urgency: 'routine',
},
});
Response Structure Changes:
interface V2Response {
answer: string;
sources: string[];
}
interface V3Response {
answer: string;
citations: Citation[];
confidence: number;
lastUpdated: string;
id: string;
}
DeepConsult Changes:
const report = await client.research('complex question');
const consultId = await client.deepConsult.create({
question: 'complex question',
context: { specialty: 'oncology', researchFocus: 'treatment' },
});
const status = await client.deepConsult.status(consultId);
Step 4: Create Migration Adapter
import { OpenEvidenceClient } from '@openevidence/sdk';
interface V2QueryResponse {
answer: string;
sources: string[];
}
interface V3QueryResponse {
answer: string;
citations: { source: string; title: string; year: number }[];
confidence: number;
}
export class OpenEvidenceMigrationAdapter {
private client: OpenEvidenceClient;
private useV3Response: boolean;
constructor(config: { apiKey: string; orgId: string; useV3Response?: boolean }) {
this.client = new OpenEvidenceClient({
apiKey: config.apiKey,
orgId: config.orgId,
});
this.useV3Response = config.useV3Response ?? false;
}
(
: ,
?: { ?: }
): <V2QueryResponse | V3QueryResponse> {
response = ..({
question,
: {
: options?. || ,
: ,
},
});
(!.) {
{
: response.,
: response..( c.),
};
}
response;
}
}
Step 5: Update Type Definitions
export interface ClinicalQueryRequest {
question: string;
context: ClinicalContext;
options?: QueryOptions;
}
export interface ClinicalContext {
specialty: string;
urgency: 'stat' | 'urgent' | 'routine' | 'research';
patientAge?: number;
patientSex?: 'male' | 'female' | 'other';
relevantConditions?: string[];
currentMedications?: string[];
}
export interface QueryOptions {
maxCitations?: number;
includeGuidelines?: boolean;
includeDrugInfo?: boolean;
preferredSources?: string[];
}
export interface Citation {
source: string;
title: string;
authors: string[];
year: ;
?: ;
?: ;
?: | | ;
?: ;
}
{
: ;
: ;
: [];
: ;
: ;
: ;
}
Step 6: Test Migration
import { describe, it, expect } from 'vitest';
import { OpenEvidenceMigrationAdapter } from '../../src/migration/openevidence-adapter';
describe('v2 to v3 Migration', () => {
const adapter = new OpenEvidenceMigrationAdapter({
apiKey: process.env.OPENEVIDENCE_API_KEY!,
orgId: process.env.OPENEVIDENCE_ORG_ID!,
useV3Response: false,
});
it('should return v2-compatible response format', async () => {
const response = await adapter.query('What is the treatment for hypertension?');
expect(response).toHaveProperty('answer');
expect(response).toHaveProperty('sources');
expect(Array.isArray((response as any).sources)).toBe(true);
});
it('should support specialty parameter', async () => {
response = adapter.(
,
{ : }
);
(response.).();
});
});
Step 7: Gradual Rollout Strategy
export const featureFlags = {
openevidence_v3_percentage: parseInt(process.env.OE_V3_PERCENTAGE || '0'),
};
export function shouldUseV3(): boolean {
return Math.random() * 100 < featureFlags.openevidence_v3_percentage;
}
async function clinicalQuery(question: string) {
if (shouldUseV3()) {
return v3ClinicalQuery(question);
}
return v2ClinicalQuery(question);
}
Migration Checklist
Output
- Updated SDK version
- Type definitions aligned with new API
- Migration adapter for gradual transition
- Tests passing with new version
Error Handling
| Migration Issue | Cause | Solution |
|---|
| Type errors | Changed response format | Update type definitions |
| Auth failures | New required fields | Add orgId to configuration |
| Missing methods | Renamed or removed | Check changelog for replacements |
| Test failures | Changed behavior | Update test expectations |
Examples
Complete Migration Script
#!/bin/bash
echo "=== OpenEvidence SDK Migration ==="
echo "Current version:"
npm list @openevidence/sdk
cp package-lock.json package-lock.json.backup
echo "Updating to latest version..."
npm install @openevidence/sdk@latest
echo "Running type check..."
npx tsc --noEmit || {
echo "Type errors found. Review and fix before continuing."
exit 1
}
echo "Running tests..."
npm test || {
echo "Tests failed. Review and fix before continuing."
exit 1
}
echo "=== Migration Complete ==="
echo "New version:"
npm list @openevidence/sdk
Resources
Next Steps
For CI/CD integration, see openevidence-ci-integration.