Skip to main content

Lens Execution Environment (LEE)

The LEE (Lens Execution Environment) is the service that executes Lens logic on p(ePI) using patient contextual data to produce the final f(ePI).

Purpose

LEE provides a sandboxed runtime environment for executing Lens JavaScript code safely and efficiently.

Execution Process

  1. Receives request from Focusing Manager
  2. Loads Lens code from FHIR Library resource
  3. Decodes Base64 content, then interprets as UTF-8 JavaScript
  4. Prepares inputs: p(ePI), IPS, PV
  5. Executes lens in isolated context
  6. Applies modifications to generate f(ePI)
  7. Returns result to Focusing Manager

Helper Methods

LEE provides APIs for Lenses to use:

modifyCSSClass()

Applies attention detail modifications:

// Function signature
modifyCSSClass(elementClass, action)

// Examples
modifyCSSClass("pregnancy-warning", "highlight");
modifyCSSClass("pediatric-info", "collapse");
modifyCSSClass("general-info", "standard");

addNewContent()

Inserts supplementary HTML:

// Function signature
addNewContent(targetLocation, htmlContent)

// Examples
addNewContent("section-4", '<a href="/sm/guide">Read more</a>');
addNewContent("warnings", '<img src="/icons/warning.png" />');
addNewContent("dosing", '<video src="/videos/howto.mp4"></video>');

Execution Modes

Client-Side Focusing

  • LEE runs in patient's browser/app
  • Uses local patient data (IPS/PV)
  • Privacy-preserving (data never leaves device)
  • Requires lightweight Lenses

Server-Side Focusing

  • LEE runs on FOSPS servers
  • Receives patient data from secure sources
  • Must scale for concurrent users
  • Enables more complex lenses

Security & Isolation

  • Sandboxed execution: Lenses cannot access system resources
  • Time limits: Prevent infinite loops
  • Memory limits: Prevent resource exhaustion
  • API restrictions: Only approved helper methods available

Architecture Position

Located in the Service Layer of FOSPS.

Integration