Get Result
Retrieve the status and download URL for a biomechanics analysis report.
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
reportId | string | Yes | Report ID from CreateReport response |
Response
| Field | Type | Description |
|---|---|---|
reportId | string | Report identifier |
status | string | Current status (see below) |
reportUrl | string | Download URL (only when status is "completed") |
occupantId | string | Occupant identifier |
occupantName | string | Occupant name for reference |
Status Values
pending- Report queued for processingprocessing- Analysis in progresscompleted- Report ready for downloadfailed- Analysis failed (contact support)
Examples
Basic Status Check
- Go
- TypeScript
import "github.com/silentwitness/go-sdk"
silentwitness.Key = "sk_test_..."
// Get report status
result, err := silentwitness.BiomechanicsAnalysis.GetResult(ctx, &silentwitness.GetBiomechanicsResultRequest{
ReportId: "bio_abc123",
})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Status: %s\n", result.Status)
if result.Status == "completed" && result.ReportUrl != nil {
fmt.Printf("Download: %s\n", *result.ReportUrl)
}
import { setApiKey, getBiomechanicsResult } from "@silentwitness/typescript-sdk";
setApiKey("sk_test_...");
// Get report status
const result = await getBiomechanicsResult({
reportId: "bio_abc123"
});
console.log(`Status: ${result.status}`);
if (result.status === "completed" && result.reportUrl) {
console.log(`Download: ${result.reportUrl}`);
}
Polling for Completion
- Go
- TypeScript
import (
"time"
"github.com/silentwitness/go-sdk"
)
// Poll until report is ready
func waitForReport(reportId string) (*silentwitness.GetBiomechanicsResultResponse, error) {
maxAttempts := 60
pollInterval := 10 * time.Second
for attempt := 0; attempt < maxAttempts; attempt++ {
result, err := silentwitness.BiomechanicsAnalysis.GetResult(ctx, &silentwitness.GetBiomechanicsResultRequest{
ReportId: reportId,
})
if err != nil {
return nil, err
}
if result.Status == "completed" {
return result, nil
}
if result.Status == "failed" {
return nil, fmt.Errorf("report generation failed")
}
time.Sleep(pollInterval)
}
return nil, fmt.Errorf("timeout waiting for report")
}
// Use the polling function
result, err := waitForReport("bio_abc123")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Report ready: %s\n", *result.ReportUrl)
// Poll until report is ready
async function waitForReport(reportId: string) {
const maxAttempts = 60;
const pollInterval = 10000; // 10 seconds
for (let attempt = 0; attempt < maxAttempts; attempt++) {
const result = await getBiomechanicsResult({ reportId });
if (result.status === "completed") {
return result;
}
if (result.status === "failed") {
throw new Error("Report generation failed");
}
// Wait before next poll
await new Promise(resolve => setTimeout(resolve, pollInterval));
}
throw new Error("Timeout waiting for report");
}
// Use the polling function
const result = await waitForReport("bio_abc123");
console.log(`Report ready: ${result.reportUrl}`);
Monitoring Multiple Reports
- TypeScript
// Check status of multiple reports from multi-occupant analysis
async function checkAllReports(reportIds: string[]) {
const results = await Promise.all(
reportIds.map(id => getBiomechanicsResult({ reportId: id }))
);
results.forEach((result, index) => {
console.log(`Occupant ${index + 1} (${result.occupantName}): ${result.status}`);
if (result.status === "completed") {
console.log(` Download: ${result.reportUrl}`);
}
});
return results;
}
// After creating multi-occupant analysis
const createResponse = await createBiomechanicsReport({
caseId: "case_123",
occupants: [/* driver and passenger */]
});
// Check all report statuses
await checkAllReports(createResponse.reportIds);
Timing Expectations
| Complexity | Typical Duration |
|---|---|
| Single injury | 2-5 minutes |
| Multiple injuries (2-3) | 5-8 minutes |
| Complex multi-injury | 8-15 minutes |
| Pregnancy complications | 10-15 minutes |
Note: Times vary based on system load and analysis complexity.
Recommended Polling Strategy
- Initial delay: Wait 2 minutes before first poll
- Poll interval: Check every 10 seconds
- Timeout: Give up after 15 minutes
- Exponential backoff: Increase interval for long-running reports
// Optimized polling with initial delay
async function smartPoll(reportId: string) {
// Wait 2 minutes before first check
await new Promise(resolve => setTimeout(resolve, 120000));
let interval = 10000; // Start with 10 seconds
const maxInterval = 30000; // Max 30 seconds
const timeout = 900000; // 15 minutes total
const startTime = Date.now();
while (Date.now() - startTime < timeout) {
const result = await getBiomechanicsResult({ reportId });
if (result.status === "completed" || result.status === "failed") {
return result;
}
await new Promise(resolve => setTimeout(resolve, interval));
// Gradually increase interval (exponential backoff)
interval = Math.min(interval * 1.2, maxInterval);
}
throw new Error("Timeout");
}
Downloading Reports
The reportUrl field contains a relative path. Construct the full URL:
const fullUrl = `https://api.silentwitness.com${result.reportUrl}`;
// Download the PDF
const response = await fetch(fullUrl, {
headers: {
'Authorization': `Bearer ${apiKey}`
}
});
const pdfBlob = await response.blob();
// Save or display PDF
Errors
| Code | Description |
|---|---|
NOT_FOUND | Report ID not found or belongs to different account |
PERMISSION_DENIED | Report not accessible |
UNAUTHENTICATED | Invalid or missing API key |
Report Contents
When status is completed, the PDF report includes:
- Executive Summary - Key findings
- Occupant Profile - Demographics and physical data
- Crash Reconstruction - Impact analysis
- Injury-Specific Analysis - For each alleged injury:
- Force calculations
- Medical tolerance thresholds
- Risk assessment
- Causation analysis
- Medical Literature - Research citations
- Expert Opinion - Professional conclusions
- Appendices - Detailed methodology
Best Practices
Efficient Polling
- Don't poll immediately; wait 2 minutes
- Use exponential backoff for long-running reports
- Set reasonable timeouts (15 minutes recommended)
Error Handling
- Check for
failedstatus and alert users - Retry on transient network errors
- Log report IDs for support requests
Multi-Occupant Reports
- Poll all reports in parallel using
Promise.all - Track progress per occupant
- Handle partial completion gracefully
Storage
- Download and store PDFs on your servers
- Don't rely on report URLs being permanent
- Cache completed reports to avoid re-downloading