定制 thibitisha/kmpdc-seeder 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thibitisha/kmpdc-seeder

Composer 安装命令:

composer require thibitisha/kmpdc-seeder

包简介

Laravel package to seed KMPDC practitioner data

README 文档

README

Latest Version on Packagist Total Downloads License: MIT Laravel PHP

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

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

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

📦 Installation

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

🧩 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 & 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

    • belongsToStatus, Speciality, SubSpeciality
    • hasManyContact, License, Qualification, PractitionerDocument, VerificationLog
  • Qualification

    • belongsToPractitioner, Degree, Institution
  • SubSpeciality

    • belongsToSpeciality
  • License

    • belongsToPractitioner
    • hasManyPayment

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

This package processes practitioner data in three main stages:

Step Command Input → Output Description
🧭 1. Sync php artisan kmpdc:sync Web data → timestamped CSV file Crawls 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 files Parses the latest CSV, extracts structured data (degrees, institutions, statuses, specialities), and saves normalized JSON files.
📥 3. Import php artisan kmpdc:import JSON files → Database Imports structured data into your Laravel models, preserving relationships and handling duplicates safely.

🧩 Run in this order: sync → extract → import

🧭 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)

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

php artisan kmpdc:extract

📥 Step 3 — Import (Save to Database)

Imports the normalized JSON into your relational schema.

php artisan kmpdc:import

🧠 Verify Imports

You can verify successful import via Tinker:

php artisan tinker
use App\Models\Practitioner;

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

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

  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 & Disclaimer

This package utilizes publicly accessible practitioner data from the
official Kenya Medical Practitioners and Dentists Council (KMPDC) 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

This package is open-sourced software licensed under the MIT license.

Author: KDBZ Repository: https://github.com/kdbz/kmpdc-seeder

thibitisha/kmpdc-seeder 适用场景与选型建议

thibitisha/kmpdc-seeder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 121 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 11 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 thibitisha/kmpdc-seeder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 thibitisha/kmpdc-seeder 我们能提供哪些服务?
定制开发 / 二次开发

基于 thibitisha/kmpdc-seeder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 121
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 15
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-01