Skip to content

feat(jubilee): add Jubilee Service Request DocType for pre-authorization#1190

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

feat(jubilee): add Jubilee Service Request DocType for pre-authorization#1190
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

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

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