Skip to Content
Health Ai PlatformWorkflowsWorkflows

Workflows

Workflows are the orchestration layer of the Health AI Platform. In this repository, they are implemented by @loop/workflow-engine and defined as data rather than hard-coded business logic.

That gives the platform three useful properties:

  • Repeatable - the same input context produces the same step execution pattern
  • Inspectable - workflow definitions can be reviewed as YAML or JSON
  • Composable - patient context, step results, and available tools are combined at runtime

What a workflow looks like

id: thyroid-assessment-v1 name: Thyroid Assessment version: 1.0.0 triggers: - type: biomarker_result params: biomarker: TSH steps: - id: check-tsh type: check_biomarker action: type: check_value params: biomarker: TSH threshold: 2.5 operator: ">" - id: recommend-selenium type: recommend_supplement condition: "check-tsh.result === true" action: type: recommend params: supplement: Selenium dosage: 200mcg

Workflow lifecycle

  1. Load a workflow definition
  2. Validate IDs, step types, and flow references
  3. Execute steps against a WorkflowContext
  4. Collect step results, recommendations, and errors
  5. Hand off outputs to downstream systems such as notifications, APIs, or agent responses

Runtime model

interface WorkflowContext { patientId: string; data?: Record<string, unknown>; tools?: string[]; }
interface WorkflowResult { success: boolean; workflowId: string; executedSteps: string[]; stepResults: Record<string, StepResult>; recommendations: Recommendation[]; errors: WorkflowError[]; }

Example execution

import { WorkflowEngine } from '@loop/workflow-engine'; WorkflowEngine.load({ id: 'thyroid-assessment-v1', name: 'Thyroid Assessment', version: '1.0.0', steps: [ { id: 'check-tsh', type: 'check_biomarker', action: { type: 'check_value', params: { biomarker: 'TSH', threshold: 2.5, operator: '>' }, }, }, { id: 'recommend-selenium', type: 'recommend_supplement', condition: 'check-tsh.result === true', action: { type: 'recommend', params: { supplement: 'Selenium', dosage: '200mcg' }, }, }, ], }); const result = await WorkflowEngine.execute('thyroid-assessment-v1', { patientId: 'patient-42', data: { biomarker: { TSH: 4.2 }, medications: ['metformin'], }, });