feat(jubilee): add send_preauthorization and refactor verify_jubilee_services in api.py#1191
Merged
av-dev2 merged 1 commit intoAakvatech-Limited:nurse-ot-modulefrom Apr 27, 2026
Conversation
…services in api.py
Extend the Jubilee API module with the SendPreauthorization endpoint
integration and refactor the verify flow to return structured data
instead of using frappe.msgprint with a primary_action button.
Imports added:
- uuid (stdlib) for potential unique ID generation
- date_diff, get_fullname from frappe.utils (used in payload construction)
verify_jubilee_services() refactored:
- When Jubilee returns a Daily Limit Exceeded / Pre-Auth required error,
the function no longer calls frappe.msgprint with a server_action button.
Instead it returns a plain dict with action, description, source_doctype,
source_docname, and benefit_code so the JS client can show a proper
freezing dialog and control the pre-auth request lifecycle.
- Fixed preapproval_status check from Accepted to OK to match the
actual Jubilee API response value.
send_preauthorization() new function:
- Accepts a Jubilee Service Request document name
- Validates that the Jubilee API is enabled in HMS TZ Setting
- Builds the full SendPreauthorization JSON payload including:
- Patient demographics: CardNo, FirstName, LastName, Gender, DateOfBirth, Age,
TelephoneNo, PatientFileNo, AuthorizationNo, AttendanceDate
- Claim metadata: ClaimYear, ClaimMonth, PatientTypeCode, DateAdmitted,
DateDischarged, PractitionerNo, ProviderID, BillNo
- Practitioner tracking: CreatedBy, DateCreated, LastModifiedBy, LastModified
- Financial: AmountClaimed, jubileeProcedure, jubileeBenefits
- FolioDiseases child list: DiseaseCode, Status, Remarks, CreatedBy, DateCreated
- FolioItems child list: ItemCode, OtherDetails, ItemQuantity, UnitPrice,
AmountClaimed, CreatedBy, DateCreated
- Posts to /jubileeapi/SendPreauthorization with Bearer token auth
- On success: parses Status, Description, SubmissionID from response;
persists them to the JSR document via frappe.db.set_value; returns
{status, submission_id, description, service_request} dict
- On exception: captures raw response text or timeout message; logs via
add_jubilee_log; persists ERROR status to the JSR document; returns
the error description in the result dict
- All API interactions are recorded via add_jubilee_log for full auditability
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.
Extend the Jubilee API module with the SendPreauthorization endpoint integration and refactor the verify flow to return structured data instead of using frappe.msgprint with a primary_action button.
Imports added:
verify_jubilee_services() refactored:
send_preauthorization() new function: