devsofttech_hms_ci4/app/Database/Migrations/2026-05-16-000204_CreateAbdmOpdTokensTable.php
DevSoftTech Server 0628f8f813 feat: ABDM OPD Queue + ABHA Register flow + patient ABHA search fix
ABDM OPD Queue (today):
- New EAtriaBridgeConnector: opdQueueFetch/opdTokenCreate/opdTokenUpdateStatus + patch() helper
- New AbdmOpdQueue controller: index/list/fetchQueue/createToken/updateTokenStatus/processScannedToken
  - fetchQueue syncs gateway tokens into abdm_opd_tokens (local DB) and enriches with HMS patient data
  - processScannedToken auto-finds/creates patient_master record from ABHA scan data, marks token CALLED
- New migration: abdm_opd_tokens table (gateway_token_id, source, status, patient_id, opd_id, processed_at)
- New view: abdm/opd_queue.php - reception screen with auto-refresh 30s, HMS Patient column (green row when OPD registered)
- Sidebar: ABDM OPD Queue nav link added
- Routes: AbdmOpdQueue with abdmPermFilter

ABHA Register tab (earlier this session):
- New Abha controller: initiate/verifyOtp/communication/verifyCommOtp/validateAbha/card + autoCreateOrFindPatient
- New views: abha/card.php, partials/abha_create_panel.php, partials/abha_otp_modal.php
- Patient_V.php: ABHA Register tab with 4-method wizard (ABHA number, QR scan, facility QR, mobile OTP)

Patient ABHA search fix:
- Patient::search() now detects ABHA column (abha_id/abha_no/abha/abha_address) and searches by it

ABDM Bridge infrastructure:
- EAtriaBridgeConnector: new connector for e-atria.in ABDM bridge gateway
- AbdmConnectorFactory/Interface updated
- AbdmGatewaySettings controller + view
- SNOMED/CSNOTK terminology service skeleton
- Finance payout OPD consult views
- Migration: AddAbdmPushFieldsToOpdAndPatient, CreateSnomedCoreTables
- Docs: abdm/ API specs, architecture, gateway guides
2026-05-16 04:21:31 +05:30

123 lines
3.6 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateAbdmOpdTokensTable extends Migration
{
public function up(): void
{
if ($this->db->tableExists('abdm_opd_tokens')) {
return;
}
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'auto_increment' => true,
],
// Gateway's own token id (unique per date)
'gateway_token_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
],
'token_number' => [
'type' => 'VARCHAR',
'constraint' => 20,
'null' => true,
],
'queue_date' => [
'type' => 'DATE',
],
'patient_name' => [
'type' => 'VARCHAR',
'constraint' => 200,
'null' => true,
],
'abha_number' => [
'type' => 'VARCHAR',
'constraint' => 20,
'null' => true,
],
'abha_address' => [
'type' => 'VARCHAR',
'constraint' => 120,
'null' => true,
],
'gender' => [
'type' => 'VARCHAR',
'constraint' => 1,
'null' => true,
],
'dob' => [
'type' => 'DATE',
'null' => true,
],
'phone' => [
'type' => 'VARCHAR',
'constraint' => 15,
'null' => true,
],
'department' => [
'type' => 'VARCHAR',
'constraint' => 120,
'default' => 'General OPD',
],
'source' => [
'type' => 'VARCHAR',
'constraint' => 30,
'default' => 'manual',
// scan_share | manual
],
'status' => [
'type' => 'ENUM',
'constraint' => ['PENDING', 'CALLED', 'COMPLETED', 'CANCELLED'],
'default' => 'PENDING',
],
// HMS links — filled after processing
'patient_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => true,
],
'opd_id' => [
'type' => 'INT',
'constraint' => 11,
'unsigned' => true,
'null' => true,
],
'processed_at' => [
'type' => 'DATETIME',
'null' => true,
],
'created_at' => [
'type' => 'DATETIME',
'null' => true,
],
'updated_at' => [
'type' => 'DATETIME',
'null' => true,
],
]);
$this->forge->addKey('id', true);
$this->forge->addUniqueKey(['gateway_token_id', 'queue_date'], 'uq_gateway_token_date');
$this->forge->addKey('queue_date');
$this->forge->addKey('status');
$this->forge->addKey('patient_id');
$this->forge->addKey('source');
$this->forge->createTable('abdm_opd_tokens');
}
public function down(): void
{
$this->forge->dropTable('abdm_opd_tokens', true);
}
}