Close icon

Get your Oystehr account

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
FREE ACCESS

Introducing Zambdas: Custom Code on a Headless EHR

September 30, 2024

Zambda Functions are ready for use in production!

Zambda Functions supplement the Oystehr platform's out-of-the-box FHIR API and services with custom functionality when you need to:

  • Integrate with a third-party service
  • Expose a custom API interface to a third-party
  • React in real-time to changes in FHIR records
  • Run custom code at intervals

One of the major benefits of building on Oystehr: no need to build your own backend. Actions like fetching available appointment slots, creating patients, inviting doctors, and filing an insurance claim for a patient all happen through Oystehr’s APIs. But in the case of integration with proprietary systems for example, custom code is required to connect.

Zambda

With Zambda Functions, you write code and Oystehr runs it. Built on top of AWS Lambda, Zambda Functions provide a secure and scalable function-as-a-service platform. Zambda Functions is launching with support for four types of functions:

  • Public. Invoked by anyone — for example, returning available appointment slots on a website for patients scheduling appointments without needing to create an account.
  • Authenticated. Invoked only by authenticated users — for example, exposing a webhook endpoint called by a third-party system notifying you when something happens (e.g. Surescripts notification of a prescription refill request).  
  • Subscription. Invoked conditionally — for example, sending patients a welcome email whenever a Patient FHIR resource is created.
  • Cron. Invoked by schedule — for example, sending an email to front-desk staff every morning with upcoming appointments.

Logs

Zamda Functions include endpoints for monitoring your functions through direct access to system logs.

Working with Oystehr Zambdas

Like every other Oystehr feature, Zambda Functions are created and modified via API endpoints. To set up a Zambda Function:

  1. Create your server-side business logic using standard Node.js.
  2. Call the create Zambda endpoint to create a function.
  3. Call the presign-s3-url endpoint to get an S3 URL to upload your custom code.
  4. Upload the code to S3, which automatically deploys the function.
  5. Call the get Zambda endpoint to get the function status.
  6. Execute the function to test it.

The Oystehr Console includes features for managing Zambda Functions that make it easier to get started.

A mockup of the Oystehr console. The page title is "Zambdas" and it has a list of Zambdas with names, methods such as http_open, statuses, and a link to each Zambda's logs.
caption...
A mockup of the Oystehr console. The page is for creating Zambdas, with fields for the Zambda name, method such as http_open, and for uploading Zambda code.

Customer Zambda Functions are live

The first production application built on Oystehr uses Zambda Functions: PM Pediatrics’ Behavioral Health Intake website. Let’s reverse-engineer how the application uses Oystehr to provide users available appointment slots.

Go ahead and load the page so you can inspect the network requests via the browser’s developer console and find the call to execute-public. This is a public Zambda Function that returns the slots available for booking. Here is a sample request to the function:

curl 'https://project-api.zapehr.com/v1/zambda/a532f706-176c-427c-a90f-e56ae7cb09d8/execute-public' -H "x-zapehr-project-id: f3d649b6-17fe-4e83-93a9-55ac48e32864" --data-raw '{"startDate":"2023-05-10T18:19:58.149-04:00"}'

Example response:

Oystehr is designed to help you build a backend for your health applications, and Zambda Functions are an important part of running your own code in the backend. They provide functionality for you to write a custom backend without needing to manage servers. Refer to our documentation on Zambdas for more information, and contact us at [email protected] or using Slack if you would like to discuss them in more detail.

Frequently Asked Questions (FAQs):

What are the key use cases for Zambdas?

Zambdas serve various purposes, including creating new FHIR resources, reacting to changes in FHIR records in real-time, integrating with third-party services, and running custom code at scheduled intervals.

What are the benefits of using Zambdas for integrating with third-party services?

Zambdas simplify the process of integrating with third-party services by allowing developers to write custom code that interacts seamlessly with external APIs, eliminating the need for building and maintaining separate backend infrastructure.

What types of functions are supported by Zambdas, and how are they invoked?

Zambdas support four types of functions: public, authenticated, subscription, and scheduled. These functions are invoked based on different criteria, such as authentication status, event triggers, or scheduled intervals.

How are Zambdas monitored and managed within the Oystehr platform?

Zambdas include endpoints for monitoring functions through direct access to system logs, allowing developers to review logs for debugging and performance monitoring purposes.

Where can I find more information and support for working with Zambdas?

More information and support for working with Zambdas can be found in the Oystehr documentation and can contact us at [email protected] or using Slack if you would like to discuss them in more detail.

Looking to try it out yourself? Request FREE access to our developer sandbox.

Get the Ultimate Headless EHR Checklist for free

  • What is a headless EHR? And how is it different from traditional EHRs?
  • Features & Functionality to
    consider
  • Cost & Pricing
  • Is a headless EHR the right fit for you?
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Stay in the know and receive regular insights, tips, and Oystehr updates by subscribing to ‘Oystehr Insights' – your pearl-sized dose of health tech updates.

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
back to blog

Learn why healthcare orgs trust Oystehr as their health tech dev platform

Meet with our engineers
Quotation icon

Our new behavioral health intake application, built on Oystehr, allowed us to build a solution that is customized for our use including scheduling, insurance validation, and direct integration with our eClinicalWorks EHR.

Mordechai Raskas
Mordechai Raskas

Chief Medical Information Officer at PM Pediatric Care