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
- Receives request from Focusing Manager
- Loads Lens code from FHIR Library resource
- Decodes Base64 content, then interprets as UTF-8 JavaScript
- Prepares inputs: p(ePI), IPS, PV
- Executes lens in isolated context
- Applies modifications to generate f(ePI)
- 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
- Called by Focusing Manager
- Retrieves Lenses from FHIR Server
- Produces f(ePI) for end-users
- Exposed via Istio VirtualService
Related Concepts
- Lens - Executed code
- p(ePI) - Input content
- f(ePI) - Output result
- Focusing Manager - Orchestrator
- Attention Modification - Primary operation
- IPS - Patient input
- Persona Vector - Context input