feat(jubilee): add Jubilee Service Request DocType for pre-authorization#1190
Merged
av-dev2 merged 1 commit intoAakvatech-Limited:nurse-ot-modulefrom Apr 27, 2026
Merged
Conversation
Introduce a new submittable DocType "Jubilee Service Request" (JSR) to manage the complete lifecycle of Jubilee Insurance pre-authorization requests. This replaces the previous ad-hoc flow and centralizes all pre-authorization logic within a structured, auditable document. DocType schema (jubilee_service_request.json): - Naming series: JSR-.YYYY.-.#### - is_submittable: True, triggers before_submit hook on document submission - Tab layout: Main info / Patient Details / Diseases / Items - Header fields: - patient_encounter (Link, required), source encounter - appointment, patient, patient_name, company (fetched/read-only) - posting_date, posting_time, patient_type_code (OP/IN) - inpatient_record (Link, read-only), for admitted/discharged logic - Service section: - jubilee_procedure (Link to Jubilee Procedure) - jubilee_benefit, benefit_code, benefit_name, benefit_balance - practitioner_no (MCT Code), provider_id, total_amount - Patient Details tab (auto-populated): - first_name, last_name, gender, date_of_birth - card_no, authorization_no, telephone_no, attendance_date - claim_month, claim_year, bill_no - admitted_date, discharge_date - Diseases tab: child table (Jubilee Service Request Disease) - Items tab: child table (Jubilee Service Request Item) - Pre-Authorization Response section (collapsible): - submission_id, preauth_status, preauth_description - Permissions: System Manager (full), Healthcare Administrator (no delete), Physician (create/read/write/share/print) Controller (jubilee_service_request.py): - before_save: calls set_missing_values() to auto-populate all fields from the linked Patient Encounter and associated records - before_submit: calls send_preauthorization() and sets preauth_status, preauth_description, submission_id on self so that Frappe final submit save includes the API response values (avoids the frappe.db.set_value overwrite issue) - set_missing_values(): orchestrates population of patient demographics, card_no, authorization_no, attendance_date, practitioner_no, provider_id, claim_year, claim_month, bill_no, diseases, items, and inpatient dates - set_diseases(): queries Codification Table joined to Patient Encounter to populate preliminary (Provisional) and final (Final) diagnoses; converts ICD code to Jubilee-compatible dotted notation - set_items(): iterates all encounter child tables via get_childs_map(), skips prescribed/cancelled/restricted/unavailable items, resolves ref_code (Jubilee item code), unit_price, and amount_claimed per item - set_inpatient_dates(): derives admitted_date and discharge_date from Inpatient Record; sets patient_type_code to IN/OP accordingly; overrides claim_year/claim_month from discharge_date for inpatients - calculate_totals(): helper to recalculate total_amount from items child table create_preauthorization_doc() whitelisted function: - Called from patient_encounter.js when doctor clicks "Request Pre-Authorization" - Looks up Jubilee Benefit for benefit_name/benefit_balance - Creates and immediately submits a JSR document, triggering before_submit which calls the Jubilee SendPreauthorization API - Calls jsr.reload() to sync in-memory object with DB values written during submit - Adds a comment on the source encounter with the result - Returns status, submission_id, description, service_request to JS for display Client script (jubilee_service_request.js): - On refresh: displays a colored dashboard headline indicator - Green: Pre-Authorization Submitted Successfully, Submission ID shown - Red: Pre-Authorization Failed with preauth_description shown
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.
Introduce a new submittable DocType "Jubilee Service Request" (JSR) to manage the complete lifecycle of Jubilee Insurance pre-authorization requests. This replaces the previous ad-hoc flow and centralizes all pre-authorization logic within a structured, auditable document.
DocType schema (jubilee_service_request.json):
Controller (jubilee_service_request.py):
create_preauthorization_doc() whitelisted function:
Client script (jubilee_service_request.js):