-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Implement a Python-based HTTP server that exposes Pathling's FHIRPath execution capabilities to FHIRPath Lab, enabling interactive FHIRPath expression evaluation and debugging through the FHIRPath Lab web interface.
Background
FHIRPath Lab is a web-based tool for experimenting with FHIRPath expressions across different FHIRPath engines. It requires server-side APIs for engines that cannot run in the browser. This issue tracks the implementation of a Pathling-based backend for FHIRPath Lab.
Requirements
API specification
The API must conform to the FHIRPath Lab server API specification:
- Accept FHIR Parameters resources as input
- Return FHIR Parameters resources as output
- Support the
POST /$fhirpath-r4endpoint - Support CORS to allow for requests originating from FHIRPath Lab domains
Core functionality
-
Execute FHIRPath expressions over arbitrary data
- Similar to the SQL-on-FHIR test runner capability
- Not limited to FHIR resources - should handle any JSON data
- Support for context expressions to establish evaluation scope
-
Input parameters (via FHIR Parameters resource):
expression(required): The FHIRPath expression to executeresource(required): The data to execute againstcontext(optional): Context expression to establish scopevariables(optional): Environment variables for the expressionvalidate(optional): Validate expression before executionterminologyServer(optional): Terminology server URL for lookups
-
Output parameters (via FHIR Parameters resource):
parameterspart containing:evaluator: Engine name and version (e.g., "Pathling 8.1.0")expression: The executed expressioncontext: The context used (if any)resource: The input resourcevariables: The variables passed (if any)parseDebugTree: Abstract Syntax Tree as JSONexpectedReturnType: Static analysis of return type
resultparts containing execution results for each context iteration- Support for trace output from
trace()function calls
-
Result format:
- Each result should include the datatype as the part name
- Support for primitive types, resource types, and complex types
- Use the
http://fhir.forms-lab.com/StructureDefinition/json-valueextension for values that cannot be represented as FHIR Parameters (e.g., backbone elements)
Library API enhancements
Expand the Pathling library API to support:
- Execution of individual FHIRPath expressions independent of FHIR resources
- Evaluation over arbitrary JSON data structures
- Access to expression parsing and type analysis information
- Support for FHIRPath variables and context expressions
Architecture
- Implementation: Python web server (Flask or FastAPI)
- Dependencies: Pathling Python library only
- Versioning: Semantic versioning, separate from other Pathling modules
- Location: New directory at the repository root (e.g.,
fhirpath-lab-api/)
Deployment
Provide AWS deployment infrastructure using CDK to enable cost-efficient hosting with acceptable user experience for FHIRPath Lab users.
Deployment options to investigate:
- AWS Lambda + Function URL: Pay-per-request pricing, zero cost when idle, cold start considerations
- AWS Lambda + HTTP API Gateway: Custom domain support, advanced routing capabilities
- AWS Lambda + Application Load Balancer: Reduced cold starts with health checks, minimum monthly cost
- ECS Fargate + Application Load Balancer: No cold starts, always-on costs
- AWS App Runner: Managed platform with auto-scaling
Key considerations:
- Cold start impact on user experience
- Cost efficiency for intermittent usage patterns
- Deployment complexity
- Pathling library size and memory requirements
- Performance requirements for FHIRPath Lab integration
Deployment artifacts should include:
- CDK stack for infrastructure as code
- GitHub Actions workflow for CI/CD
- Configuration for multiple environments (dev/staging/prod)
- Documentation for deployment and monitoring
Reference implementation
The JavaScript reference implementation provides a good example of the expected API behaviour:
- Repository: https://github.com/brianpos/fhirpath-lab-fhirpath-js-api
- Key features to replicate:
- Expression parsing and AST generation
- Debug tracing with execution traces
- Variable substitution and escape sequence handling
- Comprehensive error handling with FHIR OperationOutcome responses
Acceptance criteria
- Python server application created with separate versioning
- Library API extended to support arbitrary data evaluation
- POST endpoint implementing FHIRPath Lab specification
- Support for all required input parameters
- Output includes evaluator identification, results, and metadata
- Configurable CORS
- Error handling returns FHIR OperationOutcome resources
- Documentation for running and deploying the server
- Example requests/responses in README
- AWS CDK stack for chosen deployment option
- GitHub Actions workflow for automated deployment
- Documentation for deployment and monitoring
Metadata
Metadata
Assignees
Labels
Type
Projects
Status