- Fix groupWorkflowRowsIntoSessions() to correlate workflow rows by stable request_id/abdm_consent_request_id instead of chronological proximity to the newest CONSENT_REQUEST row. Background polling reconciles all historical sessions in one batch, so older sessions' rows previously got silently merged into the newest session, causing 'Show Data' to display an unrelated older session's single facility instead of all consented facilities. - Skip synthetic orphan sessions (stray rows with no owning CONSENT_REQUEST) in getAbdmConsentRequestsList()/getAbdmConsentArtifactDetail() so they don't show as phantom history rows or get picked as 'most recent'. - Fix abdm_documents() consent_request_id filter to match all known sibling artifact IDs for a session (via abdm_hiu_consent_artifacts), not just an exact single artifact id, so all facilities under one consent request appear together. - Fix CreateAbdmHiuConsentArtifacts migration: reduce VARCHAR(180) to VARCHAR(100) on consent_request_id/artifact_id to satisfy MySQL's 1000-byte composite key length limit (was silently failing to migrate). - Add fetchAllArtifactsAfterGrant() cascade in M3HiuWorkflowService to fetch every known artifact under a granted consent, used by both the cron poll and a new abdm_check_live_status() endpoint/button. - getLatestAbdmSyncSnapshot() session-scoping fix to avoid an older granted session masking a newer in-progress one. - Relabel Dr. Joshi Clinic documents (previously mislabeled 'Test Hospital' from the HIP's own FHIR bundle Organization name).
77 lines
2.5 KiB
PHP
77 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
/**
|
|
* Tracks every distinct ABDM consent ARTIFACT id discovered under a consent
|
|
* request. Needed because a multi-facility M3 consent produces one artifact
|
|
* per linked HIP facility, and the bridge's merged "fetch by consent_request_id"
|
|
* call does not reliably keep returning sessions for artifacts that were
|
|
* already individually resolved earlier (verified 2026-07-28: a previously
|
|
* "received" artifact stopped appearing in the merged sessions list, while
|
|
* still returning real data when queried directly by its own artifact id).
|
|
* So HMS must remember every artifact id it has ever seen for a consent
|
|
* request and keep polling each one individually, in addition to the merged
|
|
* request-id call (which is what discovers brand-new sibling artifacts).
|
|
*/
|
|
class CreateAbdmHiuConsentArtifacts extends Migration
|
|
{
|
|
public function up(): void
|
|
{
|
|
$this->forge->addField([
|
|
'id' => [
|
|
'type' => 'BIGINT',
|
|
'constraint' => 20,
|
|
'unsigned' => true,
|
|
'auto_increment' => true,
|
|
],
|
|
'consent_request_id' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 100,
|
|
],
|
|
'artifact_id' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 100,
|
|
],
|
|
'abha_address' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 120,
|
|
'null' => true,
|
|
],
|
|
'hfr_id' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 60,
|
|
'null' => true,
|
|
],
|
|
'last_status' => [
|
|
'type' => 'VARCHAR',
|
|
'constraint' => 40,
|
|
'null' => true,
|
|
],
|
|
'last_polled_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(['consent_request_id', 'artifact_id'], 'uniq_request_artifact');
|
|
$this->forge->addKey('abha_address');
|
|
$this->forge->createTable('abdm_hiu_consent_artifacts', true);
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
$this->forge->dropTable('abdm_hiu_consent_artifacts', true);
|
|
}
|
|
}
|