diff --git a/app/Views/billing/Patient_Profile_Opd_V.php b/app/Views/billing/Patient_Profile_Opd_V.php
index 8fb705e..87c438c 100644
--- a/app/Views/billing/Patient_Profile_Opd_V.php
+++ b/app/Views/billing/Patient_Profile_Opd_V.php
@@ -324,8 +324,7 @@ if ($patientPhotoPath === '') {
-
-
+
@@ -449,14 +448,7 @@ $(function() {
}
function applyConsentButtonState() {
- var $newBtn = $('#btnNewAbdmConsent');
- var canUse = autoFlowNeedsFreshRequest;
- $newBtn.toggle(canUse);
- if (canUse) {
- $('#btnAutoAbdmFlow').text('Retry Sync');
- } else {
- $('#btnAutoAbdmFlow').text('Start ABDM Sync');
- }
+ $('#btnAutoAbdmFlow').text(autoFlowTimer ? 'Fetching...' : 'Fetch Request');
}
var zoom = 1;
@@ -765,15 +757,14 @@ $(function() {
$('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text(info + (autoFlowRequestId ? (' | Request ID: ' + autoFlowRequestId) : ''));
if (resetRequestId) {
- autoFlowNeedsFreshRequest = true;
autoFlowRequestId = '';
- stopAutoFlowLoop();
- $('#btnAutoAbdmFlow').prop('disabled', false);
- updateConsentBadge('FAILED', true);
- applyConsentButtonState();
- $('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text(
- 'Previous consent request is stale/failed. Click "New Consent Request" to start a fresh request.'
- );
+ updateConsentBadge('FAILED', false);
+ $('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text('Previous consent request is stale/failed. HMS is starting a fresh request automatically.');
+ if (autoFlowAttempts < autoFlowMaxAttempts) {
+ autoFlowAttempts += 1;
+ autoFlowTimer = setTimeout(runAutoFlowStep, 1200);
+ return;
+ }
return;
}
@@ -784,7 +775,7 @@ $(function() {
return;
}
- $('#btnAutoAbdmFlow').prop('disabled', false).text('One-Click Sync');
+ $('#btnAutoAbdmFlow').prop('disabled', false);
applyConsentButtonState();
if (phase === 'COMPLETED') {
loadAbdmDocs();
@@ -854,16 +845,6 @@ $(function() {
runAutoFlowStep();
});
- $(document).off('click.abdmOpd', '#btnNewAbdmConsent').on('click.abdmOpd', '#btnNewAbdmConsent', function() {
- autoFlowNeedsFreshRequest = false;
- autoFlowRequestId = '';
- autoFlowAttempts = 0;
- stopAutoFlowLoop();
- updateConsentBadge('IDLE', false);
- applyConsentButtonState();
- $('#abdmStatusBox').removeClass('text-danger').addClass('text-muted').text('Fresh consent request context prepared. Click "Start ABDM Sync".');
- });
-
$(document).off('shown.bs.tab.abdmOpd', '[data-bs-target="#opd-abdm-tab"]').on('shown.bs.tab.abdmOpd', '[data-bs-target="#opd-abdm-tab"]', function() {
if (!currentAbdmRows.length) {
loadAbdmDocs();
diff --git a/app/Views/billing/ipd/ayushman_claim_sheet.php b/app/Views/billing/ipd/ayushman_claim_sheet.php
index ffe59e8..d041cee 100644
--- a/app/Views/billing/ipd/ayushman_claim_sheet.php
+++ b/app/Views/billing/ipd/ayushman_claim_sheet.php
@@ -55,7 +55,7 @@ $canUseM3 = $patientId > 0 && $abhaAddress !== '' && $abhaLooksVerified;
tabindex="0"
data-bs-toggle="tooltip"
data-bs-placement="top"
- title="Completed: data fetched. Granted: approved. Pending: waiting patient action. Failed: previous request failed. Failed - New Required: click New Consent Request."
+ title="Completed: data fetched. Granted: approved. Pending: waiting patient action. Failed: previous request failed. The system will restart automatically when needed."
aria-label="Consent status help"
>?
@@ -63,7 +63,6 @@ $canUseM3 = $patientId > 0 && $abhaAddress !== '' && $abhaLooksVerified;
-
@@ -185,8 +184,7 @@ $canUseM3 = $patientId > 0 && $abhaAddress !== '' && $abhaLooksVerified;
}
function applyConsentButtons() {
- $('#btnAyushmanNewConsent').toggle(needsFreshRequest);
- $('#btnAyushmanFetchAbdmM3').text(needsFreshRequest ? 'Retry ABDM M3 Sync' : 'Fetch From ABDM M3');
+ $('#btnAyushmanFetchAbdmM3').text(pollTimer ? 'Fetching...' : 'Fetch From ABDM M3');
}
function esc(value) {
@@ -346,13 +344,15 @@ $canUseM3 = $patientId > 0 && $abhaAddress !== '' && $abhaLooksVerified;
updateConsentBadge(phase, needsFreshRequest);
if (resetRequestId) {
- needsFreshRequest = true;
currentRequestId = '';
+ updateConsentBadge('FAILED', false);
+ setStatus('Previous consent request is stale/failed. HMS is starting a fresh request automatically.', false);
+ if (pollAttempts < maxPollAttempts) {
+ pollAttempts += 1;
+ pollTimer = setTimeout(runM3AutoFlow, 1200);
+ return;
+ }
stopPolling();
- $('#btnAyushmanFetchAbdmM3').prop('disabled', false);
- updateConsentBadge('FAILED', true);
- applyConsentButtons();
- setStatus('Previous consent request is stale/failed. Click "New Consent Request" and run sync again.', false);
return;
}
@@ -402,16 +402,6 @@ $canUseM3 = $patientId > 0 && $abhaAddress !== '' && $abhaLooksVerified;
runM3AutoFlow();
});
- $(document).off('click.ayushmanAbdm', '#btnAyushmanNewConsent').on('click.ayushmanAbdm', '#btnAyushmanNewConsent', function () {
- needsFreshRequest = false;
- currentRequestId = '';
- pollAttempts = 0;
- stopPolling();
- updateConsentBadge('IDLE', false);
- applyConsentButtons();
- setStatus('Fresh consent request context prepared. Click "Fetch From ABDM M3" to create a new request.', false);
- });
-
$('[data-bs-toggle="tooltip"]').tooltip();
applyConsentButtons();