Download the PHP package keenops/php-nhiftz without Composer
On this page you can find all versions of the php package keenops/php-nhiftz. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download keenops/php-nhiftz
More information about keenops/php-nhiftz
Files in keenops/php-nhiftz
Package php-nhiftz
Short Description PHP wrapper for the NHIF Tanzania ServiceHub and OCS APIs
License MIT
Homepage https://github.com/keenops/php-nhiftz
Informations about the package php-nhiftz
PHP NHIF Tanzania API Wrapper
A framework-agnostic PHP 8.2+ library for integrating with NHIF Tanzania's ServiceHub and OCS (Online Claims Submission) APIs.
Features
- Full coverage of NHIF ServiceHub API (Verification, Admissions, Approvals, Referrals, etc.)
- Full coverage of NHIF OCS API (Claims, Packages, Facilities, Reference)
- OAuth2 client credentials authentication with automatic token refresh
- PSR-18 HTTP client compatible (Guzzle included by default)
- PSR-16 cache support for token caching
- Laravel and Symfony framework integrations
- Strongly typed DTOs for request/response handling
Requirements
- PHP 8.2 or higher
- Guzzle HTTP client (or any PSR-18 compatible client)
Installation
Quick Start
Basic Usage
Card Verification with Biometrics
Patient Admission
Claim Submission
Laravel Integration
Service Provider Registration
Add the service provider to your config/app.php (Laravel < 11) or it will be auto-discovered:
Publish Configuration
Environment Variables
Add to your .env file:
Username Resolver
The NHIF API requires a username for token authentication. Instead of calling setUsername() before every request, you can configure a username resolver that dynamically resolves the username (e.g., from the authenticated user).
Option 1: Class-based resolver (recommended, config-cache safe)
Create an invokable class:
Then set it in config/nhif.php:
Option 2: Closure in AppServiceProvider
Option 3: Manual (per-request)
Usage with Facade
Usage with Dependency Injection
Symfony Integration
Register the Bundle
Configuration
Username Resolver
Register your resolver as a service, then reference it in the config:
Usage
Comprehensive Documentation
For detailed API documentation including all endpoints, parameters, payloads, and expected responses, see:
- ServiceHub API Documentation - Complete guide to all 9 ServiceHub services (~85 endpoints)
- OCS API Documentation - Complete guide to all 4 OCS services (28 endpoints)
Available Services
ServiceHub API
| Service | Description | Endpoints |
|---|---|---|
verification() |
Card verification, member details, biometrics | 18 |
admissions() |
Patient admission, discharge, transfer | 15 |
approvals() |
Service authorization and approval requests | 31 |
attendance() |
Practitioner login/logout | 2 |
history() |
Patient visit history and medical records | 3 |
issues() |
Claim issues management | 7 |
preApprovals() |
Pre-approval service requests | 6 |
reference() |
Reference data (facilities, visit types, etc.) | 4 |
referrals() |
Service and treatment referrals | 7 |
OCS API
| Service | Description | Endpoints |
|---|---|---|
claims() |
Folio submission, signing, claim retrieval | 9 |
facilities() |
Facility listing | 1 |
packages() |
Price packages, benefit schemes, services | 16 |
reference() |
Disease codes, cache management | 2 |
Error Handling
Custom HTTP Client
You can provide your own PSR-18 compatible HTTP client:
Token Caching
Provide a PSR-16 compatible cache to persist tokens:
Testing
License
The MIT License (MIT). Please see License File for more information.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
All versions of php-nhiftz with dependencies
guzzlehttp/guzzle Version ^7.0
psr/simple-cache Version ^3.0
psr/http-client Version ^1.0