Skip to content

DearDoc SDK

Version: 1.0.1Last Updated: July 14, 2025

Introduction

The DearDoc Booking App SDK allows publishers to seamlessly integrate a doctor appointment booking interface directly into their web applications. This SDK boots an iframe containing a user-friendly appointment scheduling application, enabling users to request appointments with specific healthcare providers.The application is designed to be responsive and compatible across various devices, including mobile and desktop. The core integration involves dynamically creating an iframe and loading the booking application configured for the specified provider.

Requirements

To integrate and initialize the DearDoc Booking App, you will need the following:

  • API Key: A unique API Key provided by DearDoc. Each publisher will have a different key. This key is used to authenticate requests and retrieve necessary configurations.
  • Example API Key:a0b1c2d3-e4f5-4a6b-8c7d-9e0f1a2b3c4d
  • NPI Provider ID: The National Provider Identifier (NPI) for the healthcare provider for whom the appointment booking system will be displayed. This NPI is passed within an options object during SDK initialization.
  • Example NPI: 12345678
  • Custom Merchant Id: Alternatively, the booking system can be initialized with a Merchant Id for a customer provider.
  • Example: deardoc_dev

Implementation Guide

The integration of the DearDoc Booking App is a straightforward process. You will add a script to your page that loads, initializes, and opens the booking interface.

Place the following code snippet just before the closing </body> tag of your HTML page.

JavaScript

<script type="text/javascript">
// Statement 1: Load the DearDoc SDK
(function (window, document) {
    if (window.ddBooking) {
        console.error("DearDoc Booking App embed already included");
        return;
    }
    (window.ddBooking = {}), (m = ["init", "debug", "toggleBooking"]);
    window.ddBooking._c = [];
    m.forEach(
        (me) =>
            (window.ddBooking[me] = function () {
                window.ddBooking._c.push([me, arguments]);
            })
    );
    var elt = document.createElement("script");
    elt.type = "text/javascript";
    elt.async = true;
    elt.src = "https://one.getdeardoc.com/build/shim.js?v=1.1.5";
    var before = document.getElementsByTagName("script")[0];
    before.parentNode.insertBefore(elt, before);
})(window, document, undefined);

// Statement 2: Initialize the App with your configuration
ddBooking.init(
    "aaaabbbb-1234-aaaa-bbbb-cccccccccccc", // Your API Key
    "https://one.getdeardoc.com/build",       // The build URL for the application
    "1.1.5",                                // The version of the app to load
    { 
        npi: "123456789",
        care_credit_merchant_id: "deardoc_dev"
    }  // Options object with the provider's NPI or the locations Merchant Id
);

// Statement 3: Open the booking interface
ddBooking.toggleBooking();
</script>

How It Works

This single block of code performs three main actions in sequence:

  1. Loads the SDK: The first part is an auto-executing function that:
  2. Checks if the SDK is already on the page.
  3. Creates a global ddBooking object.
  4. Creates a command queue (_c) to hold any function calls (like init or toggleBooking) made before the main script is fully downloaded.
  5. Asynchronously loads the main shim.js SDK script from the server.
  6. Initializes the App: The ddBooking.init() call configures the application. It takes the following parameters:
  7. apiKey (String, Required): Your unique publisher API Key.
  8. buildUrl (String, Required): The base URL where the application assets are hosted.
  9. version (String, Required): The specific version of the application to load.
  10. options (Object, Required): An object containing configuration parameters, most importantly the npi or the care_credit_merchant_id. It should be provided one of the 2 parameters.
  11. Opens the App: The ddBooking.toggleBooking() call is executed immediately after initialization and commands the SDK to display the booking interface to the user.

Error Handling

  • SDK Already Included: If the loader script is included multiple times, it will output a console.error('DearDoc Booking App embed already included.'); message and stop to prevent conflicts.
  • Initialization Errors: It's good practice to wrap the initialization and subsequent calls in a try...catch block to handle any unexpected runtime errors.

JavaScript

try {
  ddBooking.init(
    "dc83ec2d-1234-4bf4-1234-1bd6178a006e",
    "https://one.getdeardoc.com/build",
    "1.1.5",
    { npi: "123456789" }
  );
  ddBooking.toggleBooking();
} catch (e) {
  console.error("Error initializing DearDoc Booking App:", e);
}
  • Invalid Configuration: If an invalid API Key or NPI is provided, the SDK will load, but the iframe content itself will display an appropriate error message (e.g., "Provider not found" or "Invalid configuration"). The parent page will not throw an error, as this is handled within the iframe's application logic.