PHPackages                             thibitisha/kmpdc-seeder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. thibitisha/kmpdc-seeder

ActiveLibrary

thibitisha/kmpdc-seeder
=======================

Laravel package to seed KMPDC practitioner data

0.0.1(6mo ago)0121PHPPHP ^8.2

Since Nov 1Pushed 6mo agoCompare

[ Source](https://github.com/kdbz/kmpdc-seeder)[ Packagist](https://packagist.org/packages/thibitisha/kmpdc-seeder)[ RSS](/packages/thibitisha-kmpdc-seeder/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (38)Used By (0)

🩺 KMPDC Seeder
==============

[](#-kmpdc-seeder)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d5cd0e86ce6a7a14395839d84ea768a56ae6f72df4d338de8cd340ed184a843f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746869626974697368612f6b6d7064632d7365656465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thibitisha/kmpdc-seeder)[![Total Downloads](https://camo.githubusercontent.com/ed2a371aca40edcafbd280dda99f33e5e6e48fa4d4a23708545afed55d807d7b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746869626974697368612f6b6d7064632d7365656465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/thibitisha/kmpdc-seeder)[![License: MIT](https://camo.githubusercontent.com/942e017bf0672002dd32a857c95d66f28c5900ab541838c6c664442516309c8a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Laravel](https://camo.githubusercontent.com/3ccc671eca69e8695910518f858e08d1f046a75884b69d4821d3ccfcfee3db83/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31322e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)[![PHP](https://camo.githubusercontent.com/70442e05ca0c612056a2bc6c0bf5a5fd8c5457c9884fdcb9b2b87ccf09ccc1c7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e322d3737374242342e7376673f7374796c653d666c61742d737175617265)](https://www.php.net)

A **Laravel 12+ package** for scraping, cleaning, and importing practitioner data from the **Kenya Medical Practitioners and Dentists Council (KMPDC)** master register.

This package is designed for:

- 🧑‍🏫 Teaching structured data ingestion and seeding in Laravel

---

🚀 Features
----------

[](#-features)

✅ Scrapes KMPDC register HTML into structured CSVs
✅ Extracts &amp; normalizes:

- Practitioner details, qualifications, degrees, institutions
    ✅ Imports structured data into related tables
    ✅ Works seamlessly with Eloquent models

---

📦 Installation
--------------

[](#-installation)

```
composer require thibitisha/kmpdc-seeder:^0.0.47-alpha
```

---

🧩 Database Schema
-----------------

[](#-database-schema)

The package models relationships between practitioners, qualifications, degrees, institutions, and related entities.

 ```
erDiagram

    practitioners ||--|| statuses : has
    practitioners ||--|| specialities : belongs_to
    practitioners }o--|| sub_specialities : may_specialize_in
    practitioners ||--o{ qualifications : holds
    practitioners ||--o{ contacts : has
    practitioners ||--o{ licenses : issued
    practitioners ||--o{ practitioner_documents : uploads

    qualifications }|--|| degrees : is_type
    qualifications }|--|| institutions : awarded_by

    sub_specialities }|--|| specialities : under

    licenses ||--o{ payments : renewed_via

    users ||--|| roles : assigned_role

    verification_logs }o--|| practitioners : attempts_to_verify

    practitioners {
        BIGINT id PK
        VARCHAR registration_number UK
        VARCHAR full_name
        VARCHAR profile_photo_url "nullable"
        BIGINT status_id FK
        BIGINT speciality_id FK "nullable"
        BIGINT sub_speciality_id FK "nullable"
        DATE date_of_registration "nullable"
        TIMESTAMP created_at
        TIMESTAMP updated_at
    }

    sub_specialities {
        BIGINT id PK
        VARCHAR name
        BIGINT speciality_id FK
    }
```

      Loading > 📝 **Notes**
>
> - All inserts and relationships are handled via **Eloquent models**

---

### 🧩 **Model Setup &amp; Relationships**

[](#-model-setup--relationships)

Before running the import commands, ensure that all **Eloquent models** and their respective **relationships** are correctly defined according to the database schema provided above.

Each model should reflect its table structure and foreign key relationships.

> ⚠️ **Note:** the $fillable propery should also be defined in each model

For example:

- `Practitioner`

    - `belongsTo` → `Status`, `Speciality`, `SubSpeciality`
    - `hasMany` → `Contact`, `License`, `Qualification`, `PractitionerDocument`, `VerificationLog`
- `Qualification`

    - `belongsTo` → `Practitioner`, `Degree`, `Institution`
- `SubSpeciality`

    - `belongsTo` → `Speciality`
- `License`

    - `belongsTo` → `Practitioner`
    - `hasMany` → `Payment`

These relationships are essential for the **import command** to correctly associate records during data seeding. Ensure that:

- Foreign keys are properly defined in migrations.
- Model relationships use **typed relationship methods** (as required in Laravel 12).
- Nullable foreign keys (e.g., `speciality_id`, `sub_speciality_id`) are handled gracefully to avoid integrity constraint violations.

> ⚠️ **Note:** The package assumes these model relationships exist and are correctly implemented. Missing or incorrectly defined relationships may cause the import process to fail or produce inconsistent data.

---

🔁 Workflow Overview
-------------------

[](#-workflow-overview)

This package processes practitioner data in **three main stages**:

StepCommandInput → OutputDescription🧭 **1. Sync**`php artisan kmpdc:sync`Web data → timestamped CSV fileCrawls the KMPDC register and generates a **timestamped CSV** file containing all practitioners' details (name, registration number, qualifications, address, status, speciality, etc.).🧮 **2. Extract**`php artisan kmpdc:extract`CSV → JSON filesParses the latest CSV, extracts structured data (degrees, institutions, statuses, specialities), and saves normalized JSON files.📥 **3. Import**`php artisan kmpdc:import`JSON files → DatabaseImports structured data into your Laravel models, preserving relationships and handling duplicates safely.> 🧩 **Run in this order:** `sync → extract → import`

---

🧭 Step 1 — Sync (Generate CSV)
------------------------------

[](#-step-1--sync-generate-csv)

The sync command crawls the KMPDC register and saves a **timestamped CSV** file to your Laravel `storage` directory.

```
php artisan kmpdc:sync
```

**Output Example:**

```
storage/app/kmpdc-data/csv
└── 0000_00_00_122105_kmpdc_practitioners.csv

```

Each run produces a uniquely named file based on the timestamp, ensuring previous syncs remain preserved.

**Included columns:**

- Fullname
- Registration Number
- Address
- Qualifications
- Discipline / Speciality
- Sub-speciality
- Status
- Profile link

---

🧮 Step 2 — Extract (Generate JSON)
----------------------------------

[](#-step-2--extract-generate-json)

The extract command reads the **latest timestamped CSV** and produces clean, structured JSON files.

```
php artisan kmpdc:extract
```

---

📥 Step 3 — Import (Save to Database)
------------------------------------

[](#-step-3--import-save-to-database)

Imports the normalized JSON into your relational schema.

```
php artisan kmpdc:import
```

---

🧠 Verify Imports
----------------

[](#-verify-imports)

You can verify successful import via Tinker:

```
php artisan tinker
```

```
use App\Models\Practitioner;

Practitioner::with(['status', 'speciality', 'subSpeciality', 'qualifications'])->first();
```

---

### Examples

[](#examples)

```
use App\Models\Practitioner;

// Fetch one doctor
$doctor = Practitioner::with(['status', 'speciality', 'subSpeciality', 'qualifications.degree', 'qualifications.institution'])->first();

$doctor->full_name;             // "Dr JOHN DOE"
$doctor->status->name;          // "ACTIVE"
$doctor->speciality?->name;     // "SURGERY"
$doctor->subSpeciality?->name;  // "CARDIOLOGY"

// Get all unique institutions
\App\Models\Institution::pluck('name');

// Find all practitioners under Internal Medicine
\App\Models\Practitioner::whereHas('speciality', fn($q) => $q->where('name', 'INTERNAL MEDICINE'))->count();
```

---

🤝 Contributing
--------------

[](#-contributing)

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/my-feature`)
3. Commit your changes (`git commit -m 'Add my feature'`)
4. Push to your branch (`git push origin feature/my-feature`)
5. Open a Pull Request 🎉

---

🏛️ Acknowledgement &amp; Disclaimer
-----------------------------------

[](#️-acknowledgement--disclaimer)

This package utilizes **publicly accessible practitioner data** from the
official **[Kenya Medical Practitioners and Dentists Council (KMPDC)](https://kmpdc.go.ke/)** website.

The author, **KDBZ**, is **not affiliated with, endorsed, or sponsored by KMPDC**.
All practitioner data, formats, and associated intellectual property remain the exclusive property of KMPDC.

This project is provided **solely for educational, analytical, and research purposes**.
It is not intended for redistribution, resale, or use in any commercial or official capacity.

Users are responsible for ensuring that their use of this tool complies with:

- The **KMPDC website’s terms of service**
- Applicable **data protection and privacy laws**
- Relevant **ethical and professional standards**

> For any **commercial or institutional use**, explicit authorization should be sought directly from **KMPDC**.

📜 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

---

**Author:** [KDBZ](https://github.com/kdbz)**Repository:**

---

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance72

Regular maintenance activity

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

37

Last Release

185d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ec1bdf397ce390945bee0ce11deeb9e8cd5e7064aae3f44d480e25b888d1394?d=identicon)[kdbz](/maintainers/kdbz)

---

Top Contributors

[![kdbz](https://avatars.githubusercontent.com/u/450845?v=4)](https://github.com/kdbz "kdbz (40 commits)")

### Embed Badge

![Health badge](/badges/thibitisha-kmpdc-seeder/health.svg)

```
[![Health](https://phpackages.com/badges/thibitisha-kmpdc-seeder/health.svg)](https://phpackages.com/packages/thibitisha-kmpdc-seeder)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M2.6k](/packages/craftcms-cms)[silverstripe/framework

The SilverStripe framework

7213.5M2.5k](/packages/silverstripe-framework)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2021.0M276](/packages/drupal-core-dev)[spatie/laravel-visit

Quickly visit any route of your Laravel app

15614.6k](/packages/spatie-laravel-visit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
