chore: add ABDM M3 HIU diagnostic scripts for consent workflow debugging

This commit is contained in:
DevSoftTech Server 2026-07-28 03:08:52 +05:30
parent a1127522ef
commit 768079c970
6 changed files with 172 additions and 0 deletions

55
check_abdm_m3_status.php Normal file
View File

@ -0,0 +1,55 @@
<?php
$db = new mysqli('localhost', 'root', '', 'hms_data_ci4');
$pid = isset($argv[1]) ? (int) $argv[1] : 15;
echo "=== Patient ===\n";
$r = $db->query("SELECT id, p_fname, p_lname, abha_address FROM patient_master WHERE id = {$pid}");
$patient = $r ? $r->fetch_assoc() : null;
print_r($patient);
$abhaAddress = $patient['abha_address'] ?? '';
echo "\n=== abdm_hiu_workflows columns ===\n";
$colsResult = $db->query("SHOW COLUMNS FROM abdm_hiu_workflows");
$workflowCols = [];
while ($c = $colsResult->fetch_assoc()) {
$workflowCols[] = $c['Field'];
}
echo implode(', ', $workflowCols) . "\n";
echo "\n=== abdm_hiu_workflows (latest 15 for this ABHA / patient) ===\n";
$where = $abhaAddress !== '' ? "abha_address = '" . $db->real_escape_string($abhaAddress) . "'" : "1=0";
$result = $db->query("
SELECT *
FROM abdm_hiu_workflows
WHERE {$where}
ORDER BY id DESC
LIMIT 15
");
if ($result) {
while ($row = $result->fetch_assoc()) {
print_r($row);
}
} else {
echo "Query failed or table missing: " . $db->error . "\n";
}
echo "\n=== abdm_api_logs (latest 15) ===\n";
$result2 = $db->query("SHOW TABLES LIKE 'abdm_api_logs'");
if ($result2 && $result2->num_rows > 0) {
$cols = $db->query("SHOW COLUMNS FROM abdm_api_logs");
$colNames = [];
while ($c = $cols->fetch_assoc()) {
$colNames[] = $c['Field'];
}
echo "Columns: " . implode(', ', $colNames) . "\n\n";
$result3 = $db->query("SELECT * FROM abdm_api_logs ORDER BY id DESC LIMIT 15");
while ($row = $result3->fetch_assoc()) {
print_r($row);
}
} else {
echo "abdm_api_logs table not found.\n";
}
$db->close();

30
check_abdm_request.php Normal file
View File

@ -0,0 +1,30 @@
<?php
$db = new mysqli('localhost', 'root', '', 'hms_data_ci4');
$requestId = $argv[1] ?? 'REQ-20260728030135-90ee8841';
$escaped = $db->real_escape_string($requestId);
echo "=== abdm_hiu_workflows matching request_id/gateway_request_id/hms_request_id = {$requestId} ===\n";
$result = $db->query("
SELECT *
FROM abdm_hiu_workflows
WHERE request_id = '{$escaped}' OR gateway_request_id = '{$escaped}' OR hms_request_id = '{$escaped}'
ORDER BY id ASC
");
if ($result) {
while ($row = $result->fetch_assoc()) {
print_r($row);
}
} else {
echo "Query failed: " . $db->error . "\n";
}
echo "\n=== abdm_api_logs matching entity_id = {$requestId} ===\n";
$result2 = $db->query("SELECT * FROM abdm_api_logs WHERE entity_id = '{$escaped}' ORDER BY id ASC");
if ($result2) {
while ($row = $result2->fetch_assoc()) {
print_r($row);
}
}
$db->close();

10
check_bridge_settings.php Normal file
View File

@ -0,0 +1,10 @@
<?php
$db = new mysqli('localhost', 'root', '', 'hms_data_ci4');
$rows = $db->query("SELECT s_name, s_value FROM hospital_setting WHERE s_name IN ('EATRIA_BRIDGE_TOKEN','ABDM_HFR_ID')");
$settings = [];
while ($r = $rows->fetch_assoc()) {
$settings[$r['s_name']] = $r['s_value'];
}
echo "Token present: " . (isset($settings['EATRIA_BRIDGE_TOKEN']) && $settings['EATRIA_BRIDGE_TOKEN'] !== '' ? 'yes (len=' . strlen($settings['EATRIA_BRIDGE_TOKEN']) . ')' : 'NO') . "\n";
echo "HFR ID: " . ($settings['ABDM_HFR_ID'] ?? 'NOT SET') . "\n";
$db->close();

View File

@ -0,0 +1,13 @@
<?php
$db = new mysqli('localhost', 'root', '', 'hms_data_ci4');
$cols = $db->query('SHOW COLUMNS FROM hospital_setting');
$colNames = [];
while ($c = $cols->fetch_assoc()) {
$colNames[] = $c['Field'];
}
echo "Columns: " . implode(', ', $colNames) . "\n";
$rows = $db->query('SELECT * FROM hospital_setting LIMIT 5');
while ($r = $rows->fetch_assoc()) {
print_r($r);
}
$db->close();

View File

@ -0,0 +1,20 @@
<?php
$db = new mysqli('localhost', 'root', '', 'hms_data_ci4');
$abhaAddress = $argv[1] ?? 'meerabisht1981@sbx';
$escaped = $db->real_escape_string($abhaAddress);
$countResult = $db->query("SELECT COUNT(*) AS c FROM abdm_hiu_workflows WHERE abha_address = '{$escaped}'");
$count = $countResult->fetch_assoc()['c'] ?? 0;
echo "Rows to delete for {$abhaAddress}: {$count}\n";
$db->query("DELETE FROM abdm_hiu_workflows WHERE abha_address = '{$escaped}'");
echo "Deleted. Affected rows: " . $db->affected_rows . "\n";
$docCountResult = $db->query("SHOW TABLES LIKE 'abdm_hiu_documents'");
if ($docCountResult && $docCountResult->num_rows > 0) {
$docRows = $db->query("SELECT COUNT(*) AS c FROM abdm_hiu_documents WHERE abha_address = '{$escaped}'");
echo "Existing abdm_hiu_documents rows for {$abhaAddress}: " . ($docRows->fetch_assoc()['c'] ?? 0) . "\n";
}
$db->close();

View File

@ -0,0 +1,44 @@
<?php
$db = new mysqli('localhost', 'root', '', 'hms_data_ci4');
$rows = $db->query("SELECT s_name, s_value FROM hospital_setting WHERE s_name IN ('EATRIA_BRIDGE_TOKEN','ABDM_HFR_ID')");
$settings = [];
while ($r = $rows->fetch_assoc()) {
$settings[$r['s_name']] = $r['s_value'];
}
$db->close();
$token = trim((string) ($settings['EATRIA_BRIDGE_TOKEN'] ?? ''));
$hfrId = trim((string) ($settings['ABDM_HFR_ID'] ?? ''));
$requestId = $argv[1] ?? 'REQ-20260728030125-b03b873b';
$url = 'https://abdm-bridge.e-atria.in/api/v1/hiu/consent/status?' . http_build_query([
'request_id' => $requestId,
'hfr_id' => $hfrId,
]);
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'Accept: application/json',
'Authorization: Bearer ' . $token,
],
]);
$raw = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$err = curl_error($ch);
curl_close($ch);
echo "URL: {$url}\n";
echo "HTTP Code: {$httpCode}\n";
echo "Curl error: {$err}\n";
if ($raw !== false) {
echo "--- Headers ---\n" . substr($raw, 0, $headerSize) . "\n";
echo "--- Body (raw bytes length=" . strlen(substr($raw, $headerSize)) . ") ---\n";
echo substr($raw, $headerSize) . "\n";
}