Appointment Scheduling API

Introduction

This guide is designed to provide developers with detailed information on integrating and managing appointment scheduling within healthcare applications. Our API offers a comprehensive suite of endpoints to manage appointments, coordinate with healthcare providers, and handle patient data efficiently.

The BriteLink Appointment Scheduling API facilitates seamless interactions between different components of healthcare systems, enabling effective management of provider schedules, patient appointments, and related operations. By leveraging our API, developers can create robust applications that help healthcare facilities optimize their workflows, reduce administrative burdens, and improve patient care services.

Key Features

  • Appointment Management: Create, update, retrieve, and delete appointments with ease.
  • Provider and Patient Integration: Link appointments directly to specific healthcare providers and patients for better coordination.
  • Real-time Scheduling: Access real-time availability and scheduling capabilities to ensure up-to-date appointment booking.
  • Security and Compliance: Adhere to strict security protocols and compliance standards to protect sensitive healthcare information.

Getting Started

Before you can begin using the BriteLink API, you need to obtain credentials that will allow you to make requests to the API endpoints. Follow the steps below to get started:

  1. Create an Account: Register for an account at BriteLink Registration.
  2. Generate API Key: Once registered, navigate to your dashboard and generate API keys that you will use to authenticate requests.

Authentication

All API requests must be authenticated using an API key sent in the request header. Here is an example of how to include your API key in your requests:

GET /api/v1/premises HTTP/1.1
Host: britelink.io
Authorization: Bearer YOUR_API_KEY_HERE

Base URL

The Base URL for all API requests is https://britelink.io/api/v1/.

API Endpoints Overview

This API is structured into distinct endpoints, each designed to facilitate seamless interactions across the healthcare booking system. By integrating the Premises, Providers, Patients, and Appointments endpoints, developers can harness the full potential of a connected and interoperable healthcare ecosystem. This integrated approach not only simplifies the management of healthcare data but also enhances the functionality and user experience of your application. Additionally, developers are provided with the flexibility to either utilize BriteLink’s robust internal database for data management or opt for their own external databases. This choice allows for greater control over data storage solutions, enabling developers to align the API integration with their specific security standards, performance requirements, and scalability needs.

Using the useInternalDb Parameter

Many of the methods provided by the BriteAPI SDK include an optional parameter called useInternalDb. This parameter allows developers to specify whether they want to utilize BriteLink's internal database for data management operations. By default, this parameter is set to false, meaning that the SDK will use the default database configured for the API.

Why Use useInternalDb?

  • Flexibility: Developers can choose to use BriteLink's internal database or their own external databases based on their specific requirements.
  • Performance: Leveraging BriteLink's internal database can often lead to faster data retrieval and processing, especially for applications with large datasets.
  • Security: BriteLink's internal database is designed to adhere to strict security protocols and compliance standards, ensuring the safety and integrity of healthcare data.

Example Usage

// Create a new appointment using BriteLink's internal database
const newAppointment = {
  date: "2024-05-15",
  providerId: 123,
  patientId: 456,
  // Other appointment details...
};
const createdAppointment = await briteAPI.createAppointment(
  newAppointment,
  true
);

In the example above, the createAppointment method is called with the useInternalDb parameter set to true, indicating that BriteLink's internal database should be used for the operation.


Building a Healthcare Booking App with Next.js and BriteLink 's Appointment Scheduling API

Introduction

This tutorial will guide you through building a healthcare booking application using Next.js, leveraging the BriteLink API. By integrating endpoints for premises, providers, patients, and appointments, you'll create a highly interoperable system that can either directly interact with BriteLink's internal database or cache data locally.

Prerequisites

  • Basic knowledge of JavaScript and React
  • Familiarity with Next.js framework
  • Node.js and npm installed
  • Access to BriteLink API and valid API key

Setting Up Your Project

  1. Create a Next.js App: Start by creating a new Next.js application if you haven't already:
  1. Install Required Packages:
npm install briteapi --save
  1. Environment Setup: Configure your API keys securely:

    echo "NEXT_PUBLIC_API_URL=https://britelink.io/api/v1" >> .env.local
    echo "API_KEY=your_api_key_here" >> .env.local
    

make sure you have installed the briteapi package in your Next.js project:

Then, you can create a page component in your Next.js project to fetch and display appointments:

// app/page.js

import React, { useState, useEffect } from "react";
import { BriteAPI } from "briteapi";

const AppointmentsPage = () => {
  const [appointments, setAppointments] = useState([]);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);

  useEffect(() => {
    const fetchAppointments = async () => {
      try {
        const briteAPI = new BriteAPI("your_api_key_here");
        const fetchedAppointments = await briteAPI.fetchAppointments();
        setAppointments(fetchedAppointments);
        setLoading(false);
      } catch (error) {
        setError(error);
        setLoading(false);
      }
    };

    fetchAppointments();
  }, []);

  return (
    <div>
      <h1>Appointments</h1>
      {loading ? (
        <p>Loading...</p>
      ) : error ? (
        <p>Error: {error.message}</p>
      ) : (
        <ul>
          {appointments.map((appointment) => (
            <li key={appointment.id}>
              {appointment.date}: {appointment.title}
            </li>
          ))}
        </ul>
      )}
    </div>
  );
};

export default AppointmentsPage;

In this example, we import the BriteAPI class from the briteapi package and use it to fetch appointments in the useEffect hook. We display a loading message while fetching appointments and handle any errors that may occur. Once the appointments are fetched successfully, we display them in a list.

You can similarly create pages to perform other CRUD operations like creating, updating, and deleting appointments, patients, premises, and providers using the respective methods provided by the BriteAPI SDK. Here's a generalized example of a booking application using all the methods available in the BriteAPI SDK:

// app/booking/page
"use client";
import React, { useState, useEffect } from "react";
import { BriteAPI } from "briteapi";

const BookingPage = () => {
  const [patients, setPatients] = useState([]);
  const [premises, setPremises] = useState([]);
  const [providers, setProviders] = useState([]);
  const [appointments, setAppointments] = useState([]);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);

  useEffect(() => {
    const fetchData = async () => {
      try {
        const briteAPI = new BriteAPI("your_api_key_here");

        // Fetch patients
        const fetchedPatients = await briteAPI.fetchPatients();
        setPatients(fetchedPatients);

        // Fetch premises
        const fetchedPremises = await briteAPI.fetchPremises();
        setPremises(fetchedPremises);

        // Fetch providers
        const fetchedProviders = await briteAPI.fetchProviders();
        setProviders(fetchedProviders);

        // Fetch appointments
        const fetchedAppointments = await briteAPI.fetchAppointments();
        setAppointments(fetchedAppointments);

        setLoading(false);
      } catch (error) {
        setError(error);
        setLoading(false);
      }
    };

    fetchData();
  }, []);

  const createAppointment = async () => {
    try {
      const briteAPI = new BriteAPI("your_api_key_here");
      const newAppointment = {
        // Construct your appointment object here
      };
      await briteAPI.createAppointment(newAppointment);
      // Refresh appointments
      const fetchedAppointments = await briteAPI.fetchAppointments();
      setAppointments(fetchedAppointments);
    } catch (error) {
      setError(error);
    }
  };

  const cancelAppointment = async (id) => {
    try {
      const briteAPI = new BriteAPI("your_api_key_here");
      await briteAPI.deleteAppointment(id);
      // Refresh appointments
      const fetchedAppointments = await briteAPI.fetchAppointments();
      setAppointments(fetchedAppointments);
    } catch (error) {
      setError(error);
    }
  };

  //Add other similar methods for updating appointments, patients, premises, and providers

  return (
    <div>
      <h1>Booking Application</h1>
      {loading ? (
        <p>Loading...</p>
      ) : error ? (
        <p>Error: {error.message}</p>
      ) : (
        <div>
          {/* Render your booking components here */}
          <button onClick={createAppointment}>Create Appointment</button>
          <ul>
            {appointments.map((appointment) => (
              <li key={appointment.id}>
                {appointment.date}: {appointment.title}
                <button onClick={() => cancelAppointment(appointment.id)}>
                  Cancel
                </button>
              </li>
            ))}
          </ul>
        </div>
      )}
    </div>
  );
};

export default BookingPage;

In this example, we have a BookingPage component that fetches patients, premises, providers, and appointments using the respective methods from the BriteAPI SDK. It also includes methods to create and cancel appointments. You can expand upon this example to build a complete booking application with additional features and functionality.