Skip to content

feat(jubilee): add get_preauthorization_status endpoint and Check Status button#1194

Merged
av-dev2 merged 1 commit intoAakvatech-Limited:nurse-ot-modulefrom
av-dev2:feat_nurse_ot_module
Apr 28, 2026
Merged

feat(jubilee): add get_preauthorization_status endpoint and Check Status button#1194
av-dev2 merged 1 commit intoAakvatech-Limited:nurse-ot-modulefrom
av-dev2:feat_nurse_ot_module

Conversation

@av-dev2
Copy link
Copy Markdown
Collaborator

@av-dev2 av-dev2 commented Apr 28, 2026

Implement Jubilee API endpoint 11 (getPreauthorizationStatus) in the backend and expose a "Get Pre-Auth Status" button on the Jubilee Service Request form to allow practitioners to check the outcome of a previously submitted pre-authorization without leaving the document.

api.py — get_preauthorization_status() new whitelisted function:

  • Accepts service_request_name, loads the JSR document
  • Validates that submission_id is set (throws if missing)
  • Validates that the Jubilee API is enabled for the company
  • Sends GET /jubileeapi/getPreauthorizationStatus?submissionID= with Bearer token authorization
  • On success response (status != "ERROR"):
    • Extracts preauth_status from description.preathorizationStatus
    • Extracts preauth_description from description.details
    • Persists both values to the JSR document via frappe.db.set_value so the form reflects the latest status from Jubilee
    • Returns {status, description} to the caller
  • On API error response (status == "ERROR"):
    • Throws the error description directly so the JS onerror/msgprint handler can display the Jubilee error message to the user
  • On exception (timeout, connection error):
    • Captures raw response text or fallback message
    • Logs via add_jubilee_log with ref_doctype/ref_docname for auditability
    • Returns {status: "ERROR", description: <error_text>}

jubilee_service_request.js — form enhancements:

  • refresh: now triggers the get_preauth_status event after rendering the dashboard headline indicator so the button is always re-evaluated on every form load
  • get_preauth_status new event handler:
    • Adds a "Get Pre-Auth Status" custom button when the JSR is submitted (docstatus == 1), has a submission_id, and is not already in ERROR state
    • Button click calls get_preauthorization_status via frappe.call with freeze: true and freeze_message "Checking Pre-Auth Status..." to block the screen while waiting for the Jubilee API response
    • On success: plays success sound, shows frappe.show_alert with the preauth description, then calls frm.reload_doc() to display the newly persisted status on the document
    • On error: plays error sound, shows red frappe.msgprint with the error description from Jubilee
    • onerror: shows a generic error msgprint for unexpected JS/network failures
  • Prettier reformatting of existing string concatenation in refresh handler (no functional change)

Bug fixes applied before staging:

  • Fixed frappe.call method path from hms_tz.hms_tz.jubilee.api.api to hms_tz.jubilee.api.api (wrong double-prefix)
  • Fixed args key from jsr_name to service_request_name to match the Python function signature

…tus button

Implement Jubilee API endpoint 11 (getPreauthorizationStatus) in the
backend and expose a "Get Pre-Auth Status" button on the Jubilee Service
Request form to allow practitioners to check the outcome of a previously
submitted pre-authorization without leaving the document.

api.py — get_preauthorization_status() new whitelisted function:
- Accepts service_request_name, loads the JSR document
- Validates that submission_id is set (throws if missing)
- Validates that the Jubilee API is enabled for the company
- Sends GET /jubileeapi/getPreauthorizationStatus?submissionID=<id>
  with Bearer token authorization
- On success response (status != "ERROR"):
  - Extracts preauth_status from description.preathorizationStatus
  - Extracts preauth_description from description.details
  - Persists both values to the JSR document via frappe.db.set_value
    so the form reflects the latest status from Jubilee
  - Returns {status, description} to the caller
- On API error response (status == "ERROR"):
  - Throws the error description directly so the JS onerror/msgprint
    handler can display the Jubilee error message to the user
- On exception (timeout, connection error):
  - Captures raw response text or fallback message
  - Logs via add_jubilee_log with ref_doctype/ref_docname for auditability
  - Returns {status: "ERROR", description: <error_text>}

jubilee_service_request.js — form enhancements:
- refresh: now triggers the get_preauth_status event after rendering
  the dashboard headline indicator so the button is always re-evaluated
  on every form load
- get_preauth_status new event handler:
  - Adds a "Get Pre-Auth Status" custom button when the JSR is submitted
    (docstatus == 1), has a submission_id, and is not already in ERROR state
  - Button click calls get_preauthorization_status via frappe.call with
    freeze: true and freeze_message "Checking Pre-Auth Status..." to block
    the screen while waiting for the Jubilee API response
  - On success: plays success sound, shows frappe.show_alert with the
    preauth description, then calls frm.reload_doc() to display the
    newly persisted status on the document
  - On error: plays error sound, shows red frappe.msgprint with the
    error description from Jubilee
  - onerror: shows a generic error msgprint for unexpected JS/network failures
- Prettier reformatting of existing string concatenation in refresh handler
  (no functional change)

Bug fixes applied before staging:
- Fixed frappe.call method path from hms_tz.hms_tz.jubilee.api.api to
  hms_tz.jubilee.api.api (wrong double-prefix)
- Fixed args key from jsr_name to service_request_name to match the
  Python function signature
@av-dev2 av-dev2 merged commit 1d3b610 into Aakvatech-Limited:nurse-ot-module Apr 28, 2026
1 check failed
@codacy-production
Copy link
Copy Markdown

Not up to standards ⛔

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant