Search by

nickcheek / brightree

nickcheek

Brightree API Wrapper

Package info

github.com/nickcheek/Brightree

Homepage

pkg:composer/nickcheek/brightree

Statistics

Installs: 3 532

Dependents: 0

Suggesters: 0

Stars: 9

Open Issues: 1

v4.3.0 2026-03-24 18:44 UTC

README

Latest Version on Packagist Total Downloads

PHP wrapper for the Brightree SOAP API. It covers 13 services and 401 API methods, with fluent query builders for the search-heavy ones.

Installation

Requires PHP 7.4 or newer with the soap extension.

composer require nickcheek/brightree

Quick start

use Nickcheek\Brightree\Brightree;

$bt = new Brightree($username, $password);

$patient = $bt->Patient()->PatientFetchByBrightreeID(141508);

Pick a service from the table below, then call any of its methods. Every call returns the response object from Brightree.

Services

Each service has its own page listing every method, its arguments and the request fields it sends.

Service Accessor Methods Covers
Patient $bt->Patient() 52 Patients, contacts, notes, payors, pharmacy data and opt-in status.
SalesOrder $bt->SalesOrder() 73 Sales orders, sales order templates, schedules, WIP state, shipping and stop reasons.
Doctor $bt->Doctor() 17 Doctors, doctor notes, referral contacts, facilities and marketing reps.
Insurance $bt->Insurance() 38 Insurance records, carrier codes, span dates, payer search and price tables.
Document $bt->Document() 10 Document management: types, batches, search, storage and content.
Documentation $bt->Documentation() 55 CMNs, PARs and linking them to sales order items.
Inventory $bt->Inventory() 31 Items, locations, quantities, lots, serial numbers and item maintenance.
Pickup $bt->Pickup() 21 Pickup and exchange orders.
Reference $bt->Reference() 69 Lookup data: branches, facilities, referral contacts, users, vendors and reason lists.
Pricing $bt->Pricing() 11 Prices, price details and price tables.
Invoice $bt->Invoice() 8 Invoices and open balances.
CustomField $bt->CustomField() 3 Custom field definitions and values.
Security $bt->Security() 13 Users, user groups and permissions.

How methods are called

Methods are named after the Brightree SOAP operation they call. They come in three shapes, and each service page shows which shape a method uses.

No arguments. Mostly the FetchAll lookups.

$branches = $bt->Reference()->BranchInfoFetchAll();

Positional arguments. The wrapper builds the request for you.

$doctor = $bt->Doctor()->DoctorFetchByBrightreeID(123);
$fields = $bt->CustomField()->CustomFieldFetchAllByCategory('Patient', 1);

A request array. You pass the request as an array that matches the Brightree API definition, and it is sent as is.

$order = $bt->SalesOrder()->SalesOrderFetchByBrightreeID(['BrightreeID' => 12345]);

Query builders

The search methods on Patient, SalesOrder, Doctor, Insurance and Document have fluent builders, so you do not need to remember the request shape.

$patients = $bt->Patient()->patientQuery()
    ->lastName('Smith')
    ->firstName('John')
    ->sortBy('LastName')
    ->pageSize(25)
    ->get();

See QUERY_BUILDERS.md for examples. The filters each builder supports are listed on its service page.

For searches without a builder, the client has a small helper that assembles the search, sort and paging arrays:

$query = $bt->search(['SearchParams' => ['Branch' => ['ID' => 102]]])
    ->sort(['SortParams' => []])
    ->pageSize(50)
    ->pages(1)
    ->build();

$orders = $bt->SalesOrder()->SalesOrderSearch($query);

Error handling

Failures are thrown as Nickcheek\Brightree\Exceptions\BrightreeException, including SOAP faults and invalid arguments.

use Nickcheek\Brightree\Exceptions\BrightreeException;

try {
    $patient = $bt->Patient()->PatientFetchByBrightreeID(141508);
} catch (BrightreeException $e) {
    $e->getMessage();
    $e->getErrorData();   // SOAP fault detail, when there is one
    $e->getRequestData(); // the method and request that failed
}

getRequestData() holds the request that was sent, which can include patient information. Take care where you log it.

Custom calls

Any operation on a service endpoint that the wrapper does not define can be called with Custom():

$patient = $bt->Patient()->Custom('PatientFetchByPatientID', ['PatientID' => $id]);

Examples

Runnable scripts are in examples/.

Changelog

Please see CHANGELOG for what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email nick@nicholascheek.com.

Credits

License

The MIT License (MIT). Please see License File for more information.