devsofttech_hms_ci4/app/Database/Migrations/2026-05-19-000001_AddSnomedFulltextIndex.php
DevSoftTech Server a56e8a5776 feat: SNOMED background coding pipeline + ABDM Coding Panel
- Add opd_coding_queue + opd_snomed_suggestions migrations
- Add ProcessSnomedCoding spark command (cron: snomed:process-coding)
  Extracts clinical phrases, matches local SNOMED FULLTEXT, saves suggestions
- Add AbdmCodingPanel controller: index/review/confirm/reject/correct/mark_fhir_ready/tip_check
- Add coding_panel + coding_panel_review views (Bootstrap 5, AJAX actions)
- Inject queue trigger in opd_prescription_save (fail-open, ON DUPLICATE KEY)
- Add consult form tip badge: polls tip_check 4s after save, shows review link
- Add AbdmCodingPanel routes behind abdm permission filter
- Various ABDM gateway, FHIR, ABHA, SNOMED library updates
2026-05-19 20:40:27 +05:30

53 lines
1.4 KiB
PHP

<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
/**
* Adds a FULLTEXT index on snomed_description.term for fast in-DB SNOMED search.
* This replaces the need to call the external csnotk.e-atria.in API for every search.
* Run: php spark migrate
*/
class AddSnomedFulltextIndex extends Migration
{
public function up(): void
{
if (! $this->hasTable('snomed_description')) {
return;
}
// Check if FULLTEXT index already exists
$existing = $this->db->query(
"SHOW INDEX FROM snomed_description WHERE Index_type = 'FULLTEXT' AND Column_name = 'term'"
)->getResultArray();
if (! empty($existing)) {
return; // Already present
}
// Add FULLTEXT index — runs as online DDL (no table lock on InnoDB MySQL 5.6+)
$this->db->query('ALTER TABLE snomed_description ADD FULLTEXT INDEX ft_term (term)');
}
public function down(): void
{
if (! $this->hasTable('snomed_description')) {
return;
}
$existing = $this->db->query(
"SHOW INDEX FROM snomed_description WHERE Key_name = 'ft_term'"
)->getResultArray();
if (! empty($existing)) {
$this->db->query('ALTER TABLE snomed_description DROP INDEX ft_term');
}
}
private function hasTable(string $table): bool
{
return $this->db->tableExists($table);
}
}