- ABHA ID:
= $patientAbhaId !== '' ? esc($patientAbhaId) : 'Not available' ?>
- |
- ABHA Address:
= $patientAbhaAddress !== '' ? esc($patientAbhaAddress) : 'Not available' ?>
- |
- Status:
-
-
VERIFIED
-
-
= $abhaVerifiedStatus !== '' ? esc($abhaVerifiedStatus) : 'UNVERIFIED' ?>
-
- |
- Last Consent:
Unknown
-
?
+
+
+
+
+
ABDM M3 — Fetch Patient Health Records
+
+ ABHA Address: = $patientAbhaAddress !== '' ? esc($patientAbhaAddress) : 'Not available' ?>
+ |
+ ABHA Status:
+
+ VERIFIED
+
+ = $abhaVerifiedStatus !== '' ? esc($abhaVerifiedStatus) : 'UNVERIFIED' ?>
+
+
+
+
+
>
+
+ Fetch ABDM Records
+
+
+ Refresh list
+
+
-
-
- Refresh Fetched Data
- >Fetch Request
-
-
-
Click "Refresh Fetched Data" to load ABDM records mapped to this patient.
+
+
+ ABHA must be linked and verified for this patient before ABDM records can be requested. Verify ABHA from the patient's profile first.
+
+
+
+ One click sends a consent request to the patient's ABHA (PHR) app. Once the patient approves it there, HMS automatically fetches their health records — no need to click again.
+
+
-
-
- 1. Requested
- 2. Granted
- 3. Fetched
-
-
-
+
+
+ 1. Consent Requested
+ 2. Consent Granted
+ 3. Records Fetched
+
+
+
+ Unknown
+ Click "Fetch ABDM Records" to request and load the patient's ABDM health records.
+
+
@@ -420,6 +428,7 @@ $(function() {
var autoFlowAttempts = 0;
var autoFlowMaxAttempts = 15;
var autoFlowNeedsFreshRequest = false;
+ var autoFlowRunning = false;
function updateConsentBadge(phase, needsFresh) {
var text = (phase || '').toString().toUpperCase();
@@ -448,7 +457,9 @@ $(function() {
}
function applyConsentButtonState() {
- $('#btnAutoAbdmFlow').text(autoFlowTimer ? 'Fetching...' : 'Fetch Request');
+ $('#btnAutoAbdmFlow').prop('disabled', autoFlowRunning);
+ $('#btnAutoAbdmFlow .abdm-btn-spinner').toggleClass('d-none', !autoFlowRunning);
+ $('#btnAutoAbdmFlowLabel').text(autoFlowRunning ? 'Fetching...' : 'Fetch ABDM Records');
}
var zoom = 1;
@@ -760,7 +771,7 @@ $(function() {
autoFlowRequestId = '';
stopAutoFlowLoop();
updateConsentBadge('FAILED', false);
- $('#btnAutoAbdmFlow').prop('disabled', false);
+ autoFlowRunning = false;
applyConsentButtonState();
$('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text('Previous request is still being processed. Please wait for the first request to finish before starting a new one.');
return;
@@ -773,7 +784,7 @@ $(function() {
return;
}
- $('#btnAutoAbdmFlow').prop('disabled', false);
+ autoFlowRunning = false;
applyConsentButtonState();
if (phase === 'COMPLETED') {
loadAbdmDocs();
@@ -781,7 +792,7 @@ $(function() {
})
.catch(function(err) {
stopAutoFlowLoop();
- $('#btnAutoAbdmFlow').prop('disabled', false);
+ autoFlowRunning = false;
applyConsentButtonState();
$('#abdmStatusBox').removeClass('text-muted').addClass('text-danger').text('Auto flow failed: ' + (err.message || err));
});
@@ -827,8 +838,7 @@ $(function() {
});
$(document).off('click.abdmOpd', '#btnAutoAbdmFlow').on('click.abdmOpd', '#btnAutoAbdmFlow', function() {
- var $btn = $(this);
- if ($btn.prop('disabled')) {
+ if (autoFlowRunning) {
return;
}
stopAutoFlowLoop();
@@ -838,8 +848,9 @@ $(function() {
autoFlowNeedsFreshRequest = false;
}
setFlowProgress(1);
- $btn.prop('disabled', true).text('Sync Running...');
- $('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text('Starting one-click sync flow...');
+ autoFlowRunning = true;
+ applyConsentButtonState();
+ $('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text('Sending consent request to patient\'s ABHA app...');
runAutoFlowStep();
});