Ottehr EHR

repository·main·Indexed 43 days ago

https://github.com/masslight/ottehr

A modular, open-source Electronic Health Record (EHR) system designed for developers to fork and white-label. Version 1.42.13 leverages Oystehr as a backend service provider via Zambdas (FaaS) and includes features for external lab module management, FHIR resource integration, and DYMO label printing configuration.

Tokens
242.2K
Snippets
602
Records
895
Agent score
56%

What's inside Ottehr

  1. Overview of Synthetic Quick Picks

    main

    The Synthetic Quick Picks pipeline populates an Oystehr project's admin Quick Picks with realistic, schema-validated examples. These are project-level admin configurations used as one-click pre-fills for providers in the EHR, rather than per-visit patient data.

    It supports seven admin-managed categories:

    • procedure
    • medical-condition
    • radiology
    • allergy
    • medication-history
    • immunization
    • in-house-medication
  2. Overview of the PACS Poll Package

    main

    The pacs-poll package provides a script designed to run on a PACS gateway server. Its primary workflow involves:

    1. Polling: It monitors Oystehr projects for ServiceRequest resources that require transmission to teleradiology.
    2. Transmission: It triggers a call to a local Mirth server to send the identified studies.
    3. Updating: It patches the ServiceRequest resources to mark them as having been sent to teleradiology.
  3. What is Ottehr?

    main

    Ottehr is a modern, modular, open-source Electronic Health Record (EHR) system. It is designed to be white-labeled and customized by developers to build health-tech products.

    Ottehr uses Oystehr as a service provider to host its backend service endpoints. To run Ottehr, you must have a free Oystehr account.

    Ottehr is composed of three main components:

    • Ottehr Patient Portal (apps/intake): A patient-facing website for registration, appointments, telemedicine, and intake paperwork.
    • Ottehr EHR (apps/ehr/): A staff-facing application for managing appointments, patient queues, medical charting (HPI, exam, assessment), eRx, and RCM/claims.
    • Ottehr Backend (packages/zambdas): A collection of Function-as-a-Service (FaaS) endpoints deployed as Oystehr Zambdas.
  4. Overview of Ottehr E2E testing capabilities

    main

    The E2E testing system uses Playwright to validate two main applications:

    1. EHR (Electronic Health Records): Provider-facing app for managing appointments, medical records, and clinical workflows.
    2. Intake: Patient-facing portal for booking, forms, insurance, and payments.

    Key Features

    • Fast Test Mode: Uses single atomic FHIR transactions instead of multi-step API orchestration.
    • Contract Testing: Ensures Fast Mode produces results identical to standard testing.
    • Multi-Environment Support: Supports Local, Demo, and Staging with automatic resource discovery.
    • Authentication Handling: Supports username/password for providers and SMS verification for patients.
    • FHIR Resource Management: Automated creation, lifecycle management, and cleanup of FHIR resources.
    • Parallel Execution: Supports multiple test workers with resource isolation.
  5. Overview of the External Labs Module

    main

    The External Labs Module manages lab ordering and result flows. It integrates the Ottehr (frontend EHR) UI, zambdas (EHR backend), and Oystehr (services backend) calls.

    Key functionalities include:

    • Accessing searchable live lab compendium information (tests, codes, specimen collection info).
    • Order submission.
    • Result parsing.
    • Route creation.

    Integration with LabCorp or Quest via Ottehr/Oystehr requires the use of this module, as it is certified for ordering labs, displaying results, and handling unsolicited results.

  6. Overview of the Ottehr Patient Portal

    main

    The Ottehr Patient Portal (intake-ui) is a static frontend web application designed for patients. It allows users to manage their healthcare journey by performing the following tasks:

    • Signing up for appointments
    • Scheduling new appointments
    • Canceling appointments
    • Rescheduling appointments
    • Completing paperwork for upcoming appointments
  7. Overview of Synthetic Patient Data Helper Scripts

    main

    The scripts/synthetic-patient-data/ directory contains helper scripts designed to support the synthesize-visit.ts orchestrator. These scripts allow for managing the lifecycle of synthetic data, including provisioning users, copying templates/medications, inspecting project state, and cleaning up generated resources.

    Important Note: Most scripts default to a dry-run mode. To actually commit changes (write to the project), you must include the --execute flag.

  8. Understand the structure of a fax packet

    main

    When sending a fax, the system generates a single merged PDF called a fax packet. You cannot select individual documents; the entire visit package is sent. The merge order is fixed by FAX_DOCUMENT_ORDER and follows this sequence:

    1. Cover sheet
    2. Visit/Progress Note (Always included)
    3. Discharge Summary (Included if a DocumentReference with ID discharge-summary exists)
    4. Lab Results (Included if there is $\ge 1$ reviewed result with DocumentReference LOINC 11502-2 and docStatus === 'final')
    5. Radiology Results (Included if $\ge 1$ result is found via searchRadiologyResultDocRefs over the encounter's ServiceRequests)
    6. Patient Education (Included if $\ge 1$ document exists and no discharge summary is present in the packet)

    Note: Prescriptions and Patient Instructions are treated as sections within the Visit/Progress Note and are not sent as standalone documents. Additionally, if a Discharge Summary is included, Patient Education documents are automatically dropped to prevent duplication.

  9. Implement Config-Aware Testing

    main

    Config-aware testing allows E2E tests to adapt to different application configurations (like feature flags or UI options) without hardcoding expectations. This is achieved by injecting configuration overrides into the browser context before navigation.

    Implementation Pattern

    1. Inject Config: Use injectTestConfig() to pass overrides via window[CONFIG_KEY] using Playwright's addInitScript().
    2. Timing: You must call injectTestConfig() before calling page.goto().
    3. Consumption: The application uses a Proxy object that checks the window for these test overrides at runtime. If no override is found, it falls back to the default application configuration.

    Benefits

    • Isolation: Each test can have its own unique configuration via addInitScript().
    • Adaptability: Tests automatically adjust to changes in ottehr-config or instance-specific defaults.ts files.
    import { CONFIG_INJECTION_KEYS } from 'utils';
    import { injectTestConfig } from '../config/injectTestConfig';
    
    // 1. Inject booking config overrides BEFORE navigation
    await injectTestConfig(page, CONFIG_INJECTION_KEYS.BOOKING, bookingOverrides);
    
    // 2. Navigate to the page
    await page.goto('/home');
    
    // The application's BOOKING_CONFIG proxy will now use the overrides
  10. How the Billing Report Refresh Framework works

    main

    The Billing Report Refresh Framework uses a task/subscribe pipeline to compute, cache, and serve reports without overloading the HTTP layer.

    Core Workflow:

    1. HTTP Request: The get-billing-report zambda serves a cached snapshot and a refresh status. It never computes data itself.
    2. Task Queuing: If a refresh is requested, the HTTP zambda queues an asynchronous FHIR Task.
    3. Worker Execution: A subscription worker (sub-refresh-billing-report) picks up the Task, runs the report's compute() method, and streams progress back to the Task.
    4. Caching: The worker writes the resulting payload and optional drilldown datasets as gzipped JSON objects to the billing-app Z3 bucket.
    5. Frontend Consumption: The frontend polls the HTTP endpoint for status. When ready, it uses a short-lived presigned URL to download the payload directly from Z3, bypassing the HTTP zambda to ensure high performance for large datasets.

    Key Invariants:

    • The FHIR Task is the single source of truth for refresh state.
    • The Z3 cache objects are the single source of truth for report data.
  11. Understand the Ottehr visit lifecycle and status transitions

    main

    Ottehr uses a custom 'visit status' workflow layered over standard FHIR Appointment.status and Encounter.status. This custom status is displayed on the staff dashboard and is synchronized across Encounter.statusHistory and Appointment audit-log meta tags.

    For walk-in urgent care, the lifecycle follows this sequence: arrived → ready → intake → ready for provider → provider → discharged → completed → (signed)

    Key Behaviors:

    • Target Status: In synthetic scenarios, you can set visit.targetStatus to any valid state (e.g., 'intake', 'provider'). The pipeline will truncate the workflow at that state. If the target is not 'completed', the visit remains unlocked (no APPOINTMENT_LOCKED tag).
    • Clinical Phases: Clinical data entry (chart data, orders, etc.) occurs independently of the dashboard status. A chart can be fully populated even if the visit is in an early lifecycle stage (e.g., intake).
  12. Organize E2E tests in the EHR and Intake apps

    main

    The project uses a structured approach to separate workflow testing, infrastructure, and UI abstractions.

    EHR Application Structure

    • apps/ehr/tests/e2e/specs/*.spec.ts: Primary test scenarios and user workflow validation.
    • apps/ehr/tests/e2e/page/: Page Object Models (POMs) including abstract base classes and specific pages (e.g., in-person, telemed).
    • apps/ehr/tests/e2e/e2e-utils/: Helper utilities like ResourceHandler for FHIR resource management.
    • apps/ehr/tests/e2e/login/: Authentication establishment logic.
    • apps/ehr/tests/e2e/seed-data/: Auto-generated test data (the resources/ directory is git-ignored).

    Intake Application Structure

    • apps/intake/tests/specs/: Primary test scenarios (e.g., in-person or telemed booking tests).
    • apps/intake/tests/utils/: Test utilities.
    • apps/intake/tests/login/: Authentication establishment.
    • apps/intake/playwright/: Playwright configuration.
    • apps/intake/playwright-report/: Test reports.