Skip to main content
Back to Prompt Library
implementation

Generate FHIR Genomic Report with AI SDK

Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.

Linked challenge: Newborn Genomic Screening Risk Classifier using AI SDK and FHIR Integration

Format
Code-aware
Lines
18
Sections
3
Linked challenge
Newborn Genomic Screening Risk Classifier using AI SDK and FHIR Integration

Prompt source

Original prompt text with formatting preserved for inspection.

18 lines
3 sections
No variables
0 checklist items
import { generateObject } from 'ai';
import { openai } from '@ai-sdk/openai';
import { z } from 'zod';

// Define Zod schema matching HL7 FHIR DiagnosticReport
const FhirReportSchema = z.object({
  resourceType: z.literal('DiagnosticReport'),
  status: z.enum(['registered', 'partial', 'preliminary', 'final']),
  subject: z.object({ reference: z.string() }),
  conclusion: z.string(),
});

export async function processNewbornGenomics(inputData) {
  const result = await generateObject({
    model: openai('gpt-4o'),
    schema: FhirReportSchema,
    prompt: `Analyze newborn variants and generate FHIR DiagnosticReport: ${JSON.stringify(inputData)}`,
  });
  return result.object;
}

Adaptation plan

Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.

Keep stable

Hold the task contract and output shape stable so generated implementations remain comparable.

Tune next

Update libraries, interfaces, and environment assumptions to match the stack you actually run.

Verify after

Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.