Skip to content

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
av-dev2:feat_nurse_ot_module
Apr 27, 2026
Merged

feat(jubilee): add send_preauthorization and refactor verify_jubilee_services in api.py#1191
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 27, 2026

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

…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
@av-dev2 av-dev2 merged commit ddfc57b into Aakvatech-Limited:nurse-ot-module Apr 27, 2026
@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