feat(jubilee): add Jubilee inpatient admission status check#1195
Merged
av-dev2 merged 1 commit intoAakvatech-Limited:nurse-ot-modulefrom Apr 28, 2026
Merged
Conversation
… 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
Not up to standards ⛔
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
inpatient_record.js - integrate Jubilee into admit_patient_dialog: