Skip to content

feat(jubilee): add Jubilee inpatient admission status check#1195

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

feat(jubilee): add Jubilee inpatient admission status check#1195
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 12 (getAdmissionStatus) and integrate it into the Inpatient Record admit flow, mirroring the existing nhif_admit_patient pattern so Jubilee patients are verified with the insurer before being admitted.

api.py - get_inpatient_admission_status() new whitelisted function:

  • Accepts inpatient_record_name and loads the Inpatient Record document
  • Resolves the authorization number from the linked Patient Appointment (patient_appointment.authorization_no) rather than from Insurance Subscription, which is the correct source for Jubilee authorization data
  • Guards: throws if authorization_no is missing; throws if Jubilee API is not enabled for the company via HMS TZ Setting.enable_jubilee_api
  • Sends GET /jubileeapi/getAdmissionStatus?authorizationNo=<auth_no> with Bearer token authorization header
  • On success response (status == OK):
    • Extracts fromDate, toDate, approvedAmount from the description object
    • Extracts admitted_datetime and expected_discharge for future persistence (db.set_value is commented out for now, pending field confirmation)
    • Returns {status, description} with the full admission detail dict
  • On error response (status == ERROR):
    • Throws the Jubilee error description directly so the JS onerror handler shows the insurer exact error to the user
  • On exception (timeout, connection error):
    • Captures raw response text or fallback message
    • Logs via add_jubilee_log with ref_doctype Inpatient Record and card_no set to the authorization number for full auditability
    • Returns {status: ERROR, description: <error_text>}

inpatient_record.js - integrate Jubilee into admit_patient_dialog:

  • primary_action_label: changed to show Next for both NHIF and Jubilee patients (previously only NHIF showed Next); plain admit shows Admit
  • primary_action: converted from 2-branch to 3-branch logic:
    1. NHIF patients: unchanged, checks enable_nhif_api, calls nhif_admit_patient
    2. Jubilee patients: checks enable_jubilee_api via frappe.db.get_value; if enabled, calls jubilee_admit_patient(); otherwise falls back to direct admit_patient() without API verification
    3. All other patients: direct admit_patient() (unchanged)
  • jubilee_admit_patient() new function:
    • Hides the admit dialog immediately to prevent double-clicks
    • Calls get_inpatient_admission_status with freeze: true and freeze_message to block the UI during the API call
    • On status OK: shows a green frappe.show_alert with the approval number and approved amount from the Jubilee response, then calls admit_patient() to complete the standard Frappe admission flow
    • onerror: plays error sound and shows a red frappe.msgprint with a generic error message for unexpected network or JS failures

… 12)

Implement Jubilee API endpoint 12 (getAdmissionStatus) and integrate it
into the Inpatient Record admit flow, mirroring the existing nhif_admit_patient
pattern so Jubilee patients are verified with the insurer before being admitted.

api.py - get_inpatient_admission_status() new whitelisted function:
- Accepts inpatient_record_name and loads the Inpatient Record document
- Resolves the authorization number from the linked Patient Appointment
  (patient_appointment.authorization_no) rather than from Insurance
  Subscription, which is the correct source for Jubilee authorization data
- Guards: throws if authorization_no is missing; throws if Jubilee API is
  not enabled for the company via HMS TZ Setting.enable_jubilee_api
- Sends GET /jubileeapi/getAdmissionStatus?authorizationNo=<auth_no>
  with Bearer token authorization header
- On success response (status == OK):
  - Extracts fromDate, toDate, approvedAmount from the description object
  - Extracts admitted_datetime and expected_discharge for future persistence
    (db.set_value is commented out for now, pending field confirmation)
  - Returns {status, description} with the full admission detail dict
- On error response (status == ERROR):
  - Throws the Jubilee error description directly so the JS onerror
    handler shows the insurer exact error to the user
- On exception (timeout, connection error):
  - Captures raw response text or fallback message
  - Logs via add_jubilee_log with ref_doctype Inpatient Record and
    card_no set to the authorization number for full auditability
  - Returns {status: ERROR, description: <error_text>}

inpatient_record.js - integrate Jubilee into admit_patient_dialog:
- primary_action_label: changed to show Next for both NHIF and Jubilee
  patients (previously only NHIF showed Next); plain admit shows Admit
- primary_action: converted from 2-branch to 3-branch logic:
  1. NHIF patients: unchanged, checks enable_nhif_api, calls nhif_admit_patient
  2. Jubilee patients: checks enable_jubilee_api via frappe.db.get_value;
     if enabled, calls jubilee_admit_patient(); otherwise falls back to
     direct admit_patient() without API verification
  3. All other patients: direct admit_patient() (unchanged)
- jubilee_admit_patient() new function:
  - Hides the admit dialog immediately to prevent double-clicks
  - Calls get_inpatient_admission_status with freeze: true and
    freeze_message to block the UI during the API call
  - On status OK: shows a green frappe.show_alert with the approval number
    and approved amount from the Jubilee response, then calls admit_patient()
    to complete the standard Frappe admission flow
  - onerror: plays error sound and shows a red frappe.msgprint with a
    generic error message for unexpected network or JS failures
@av-dev2 av-dev2 merged commit 73ee910 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