@ampath/esm-dha-workflow-app 4.0.0-next.33 → 4.0.0-next.331
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/1149.js +1 -0
- package/dist/1149.js.map +1 -0
- package/dist/1197.js +1 -0
- package/dist/1362.js +1 -0
- package/dist/1362.js.map +1 -0
- package/dist/1551.js +1 -0
- package/dist/1551.js.map +1 -0
- package/dist/1925.js +1 -0
- package/dist/1925.js.map +1 -0
- package/dist/1927.js +1 -0
- package/dist/1927.js.map +1 -0
- package/dist/203.js +1 -0
- package/dist/203.js.map +1 -0
- package/dist/2054.js +1 -0
- package/dist/2054.js.map +1 -0
- package/dist/2093.js +1 -0
- package/dist/2093.js.map +1 -0
- package/dist/2177.js +2 -0
- package/dist/2177.js.map +1 -0
- package/dist/2200.js +1 -0
- package/dist/2200.js.map +1 -0
- package/dist/2230.js +1 -0
- package/dist/2230.js.map +1 -0
- package/dist/2493.js +1 -0
- package/dist/2493.js.map +1 -0
- package/dist/262.js +2 -0
- package/dist/262.js.map +1 -0
- package/dist/2914.js +1 -0
- package/dist/2914.js.map +1 -0
- package/dist/2936.js +1 -0
- package/dist/2936.js.map +1 -0
- package/dist/2988.js +1 -0
- package/dist/2988.js.map +1 -0
- package/dist/3041.js +1 -0
- package/dist/3041.js.map +1 -0
- package/dist/307.js +1 -0
- package/dist/307.js.map +1 -0
- package/dist/3099.js +1 -0
- package/dist/3184.js +2 -0
- package/dist/3184.js.map +1 -0
- package/dist/3202.js +1 -0
- package/dist/3202.js.map +1 -0
- package/dist/3222.js +1 -0
- package/dist/3222.js.map +1 -0
- package/dist/3406.js +1 -0
- package/dist/3406.js.map +1 -0
- package/dist/347.js +1 -0
- package/dist/347.js.map +1 -0
- package/dist/3654.js +1 -0
- package/dist/3654.js.map +1 -0
- package/dist/4003.js +1 -0
- package/dist/4003.js.map +1 -0
- package/dist/4008.js +1 -0
- package/dist/4008.js.map +1 -0
- package/dist/4055.js +1 -0
- package/dist/4205.js +1 -0
- package/dist/4205.js.map +1 -0
- package/dist/4225.js +1 -0
- package/dist/4225.js.map +1 -0
- package/dist/4231.js +1 -0
- package/dist/4231.js.map +1 -0
- package/dist/4300.js +1 -0
- package/dist/4335.js +1 -0
- package/dist/4353.js +1 -0
- package/dist/4353.js.map +1 -0
- package/dist/4431.js +1 -0
- package/dist/4431.js.map +1 -0
- package/dist/4454.js +1 -0
- package/dist/4454.js.map +1 -0
- package/dist/4457.js +2 -0
- package/dist/4457.js.LICENSE.txt +282 -0
- package/dist/4457.js.map +1 -0
- package/dist/446.js +1 -0
- package/dist/446.js.map +1 -0
- package/dist/4611.js +1 -0
- package/dist/4611.js.map +1 -0
- package/dist/4652.js +1 -0
- package/dist/4674.js +1 -0
- package/dist/4674.js.map +1 -0
- package/dist/4755.js +1 -0
- package/dist/4755.js.map +1 -0
- package/dist/4986.js +1 -0
- package/dist/4986.js.map +1 -0
- package/dist/5097.js +1 -0
- package/dist/5097.js.map +1 -0
- package/dist/5119.js +1 -0
- package/dist/5119.js.map +1 -0
- package/dist/5167.js +1 -0
- package/dist/5167.js.map +1 -0
- package/dist/5380.js +1 -0
- package/dist/5380.js.map +1 -0
- package/dist/5422.js +1 -0
- package/dist/5422.js.map +1 -0
- package/dist/5576.js +1 -0
- package/dist/5576.js.map +1 -0
- package/dist/5851.js +1 -0
- package/dist/5851.js.map +1 -0
- package/dist/5961.js +1 -0
- package/dist/5961.js.map +1 -0
- package/dist/6264.js +1 -0
- package/dist/6264.js.map +1 -0
- package/dist/6540.js +2 -0
- package/dist/6540.js.map +1 -0
- package/dist/6606.js +1 -0
- package/dist/6606.js.map +1 -0
- package/dist/6720.js +1 -0
- package/dist/6720.js.map +1 -0
- package/dist/6824.js +1 -0
- package/dist/6824.js.map +1 -0
- package/dist/6942.js +1 -0
- package/dist/6942.js.map +1 -0
- package/dist/71.js +1 -0
- package/dist/71.js.map +1 -0
- package/dist/7207.js +1 -0
- package/dist/7207.js.map +1 -0
- package/dist/7240.js +1 -0
- package/dist/7240.js.map +1 -0
- package/dist/7255.js +1 -0
- package/dist/7255.js.map +1 -0
- package/dist/7271.js +1 -0
- package/dist/7271.js.map +1 -0
- package/dist/7420.js +1 -0
- package/dist/7420.js.map +1 -0
- package/dist/7521.js +1 -0
- package/dist/7521.js.map +1 -0
- package/dist/7557.js +1 -0
- package/dist/7557.js.map +1 -0
- package/dist/7717.js +1 -0
- package/dist/7717.js.map +1 -0
- package/dist/7830.js +2 -0
- package/dist/7830.js.map +1 -0
- package/dist/7879.js +1 -0
- package/dist/7879.js.map +1 -0
- package/dist/7941.js +1 -0
- package/dist/7941.js.map +1 -0
- package/dist/8091.js +1 -0
- package/dist/8091.js.map +1 -0
- package/dist/810.js +1 -2
- package/dist/810.js.map +1 -1
- package/dist/8558.js +1 -0
- package/dist/8558.js.map +1 -0
- package/dist/8733.js +1 -0
- package/dist/8733.js.map +1 -0
- package/dist/874.js +1 -0
- package/dist/874.js.map +1 -0
- package/dist/8895.js +1 -0
- package/dist/8895.js.map +1 -0
- package/dist/9070.js +1 -0
- package/dist/9070.js.map +1 -0
- package/dist/9091.js +1 -0
- package/dist/9091.js.map +1 -0
- package/dist/9093.js +1 -0
- package/dist/9093.js.map +1 -0
- package/dist/9249.js +1 -0
- package/dist/9249.js.map +1 -0
- package/dist/9338.js +1 -0
- package/dist/9338.js.map +1 -0
- package/dist/9418.js +2 -0
- package/dist/9418.js.LICENSE.txt +1 -0
- package/dist/9418.js.map +1 -0
- package/dist/9428.js +1 -0
- package/dist/9428.js.map +1 -0
- package/dist/9721.js +1 -0
- package/dist/9721.js.map +1 -0
- package/dist/esm-dha-workflow-app.js +1 -1
- package/dist/esm-dha-workflow-app.js.buildmanifest.json +1675 -210
- package/dist/esm-dha-workflow-app.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/local-config.json +5 -0
- package/package.json +16 -6
- package/src/admissions/admission-request-list/admission-request-list.scss +0 -0
- package/src/admissions/admission-request-list/admission-request-list.tsx +263 -0
- package/src/admissions/admissions-dashboard.component.scss +15 -0
- package/src/admissions/admissions-dashboard.component.tsx +277 -0
- package/src/admissions/admissions.resource.ts +233 -0
- package/src/admissions/admitted-list/admitted-patients-list.tsx +206 -0
- package/src/admissions/awaiting-discharge-list/awaiting-discharge-list.tsx +197 -0
- package/src/admissions/bed-assigment-request/bed-assignment-request-list.tsx +134 -0
- package/src/admissions/constants/index.ts +33 -0
- package/src/admissions/discharged-list/discharged-list.scss +0 -0
- package/src/admissions/discharged-list/discharged-list.tsx +67 -0
- package/src/admissions/form-entry-workspace/form-entry-workspace.tsx +62 -0
- package/src/admissions/inpatient/admission-history/patient-admission-history.tsx +76 -0
- package/src/admissions/inpatient/admission-requests/patient-admission-requests.scss +19 -0
- package/src/admissions/inpatient/admission-requests/patient-admission-requests.tsx +72 -0
- package/src/admissions/inpatient/inpatient-admissions.component.scss +7 -0
- package/src/admissions/inpatient/inpatient-admissions.component.tsx +46 -0
- package/src/admissions/modal/add-bill-items/add-bill-items.modal.scss +17 -0
- package/src/admissions/modal/add-bill-items/add-bill-items.modal.tsx +233 -0
- package/src/admissions/modal/admit-elsewhere/admit-elsewhere.modal.scss +23 -0
- package/src/admissions/modal/admit-elsewhere/admit-elsewhere.modal.tsx +156 -0
- package/src/admissions/modal/admit-patient/admit-patient.modal.scss +0 -0
- package/src/admissions/modal/admit-patient/admit-patient.modal.tsx +111 -0
- package/src/admissions/modal/bed-swap/bed-swap.modal.scss +0 -0
- package/src/admissions/modal/bed-swap/bed-swap.modal.tsx +102 -0
- package/src/admissions/modal/cancel-admission-request/cancel-admission-request.scss +11 -0
- package/src/admissions/modal/cancel-admission-request/cancel-admission-request.tsx +105 -0
- package/src/admissions/modal/discharge/discharge-patient.modal.scss +13 -0
- package/src/admissions/modal/discharge/discharge-patient.modal.tsx +86 -0
- package/src/admissions/types/index.ts +263 -0
- package/src/appointments/appointments.component.scss +6 -0
- package/src/appointments/appointments.component.tsx +8 -1
- package/src/billing/api/billing.api.ts +139 -0
- package/src/billing/billing-claims.resource.ts +900 -0
- package/src/billing/billing-dashboard-link.component.tsx +31 -0
- package/src/billing/billing-dashboard-reset.ts +27 -0
- package/src/billing/billing-root.tsx +42 -0
- package/src/billing/dashboard/billingDashboard.component.scss +0 -0
- package/src/billing/dashboard/billingDashboard.component.tsx +25 -0
- package/src/billing/dashboard/v2/active-visits/active-visits.component.tsx +257 -0
- package/src/billing/dashboard/v2/active-visits/active-visits.resource.ts +85 -0
- package/src/billing/dashboard/v2/active-visits/active-visits.scss +15 -0
- package/src/billing/dashboard/v2/active-visits.component.tsx +102 -0
- package/src/billing/dashboard/v2/admissions/admission-requests-tab.component.tsx +79 -0
- package/src/billing/dashboard/v2/billing-claims-dashboard.component.scss +209 -0
- package/src/billing/dashboard/v2/billing-claims-dashboard.component.tsx +347 -0
- package/src/billing/dashboard/v2/cash-checklist/bill-document.component.scss +90 -0
- package/src/billing/dashboard/v2/cash-checklist/bill-document.component.tsx +101 -0
- package/src/billing/dashboard/v2/cash-checklist/cash-checklist.component.scss +199 -0
- package/src/billing/dashboard/v2/cash-checklist/cash-checklist.component.tsx +361 -0
- package/src/billing/dashboard/v2/cash-checklist/cash-checklist.resource.ts +239 -0
- package/src/billing/dashboard/v2/cash-checklist/payment-drawer.component.scss +246 -0
- package/src/billing/dashboard/v2/cash-checklist/payment-drawer.component.tsx +182 -0
- package/src/billing/dashboard/v2/claim-statuses.ts +143 -0
- package/src/billing/dashboard/v2/claim-visits/claim-diagnosis-details/claim-diagnosis-details.component.scss +0 -0
- package/src/billing/dashboard/v2/claim-visits/claim-diagnosis-details/claim-diagnosis-details.component.tsx +35 -0
- package/src/billing/dashboard/v2/claim-visits/claim-diagnosis-details/claim-diagnosis-panel.component.scss +67 -0
- package/src/billing/dashboard/v2/claim-visits/claim-diagnosis-details/claim-diagnosis-panel.component.tsx +90 -0
- package/src/billing/dashboard/v2/claim-visits/claim-doctors/claim-doctors.scss +28 -0
- package/src/billing/dashboard/v2/claim-visits/claim-doctors/claim-doctors.tsx +36 -0
- package/src/billing/dashboard/v2/claim-visits/claim-history/claim-history.component.scss +119 -0
- package/src/billing/dashboard/v2/claim-visits/claim-history/claim-history.component.tsx +198 -0
- package/src/billing/dashboard/v2/claim-visits/claim-intervention-details/claim-intervention-details.component.scss +5 -0
- package/src/billing/dashboard/v2/claim-visits/claim-intervention-details/claim-intervention-details.component.tsx +160 -0
- package/src/billing/dashboard/v2/claim-visits/claim-intervention-details/claim-intervention-panel.component.scss +105 -0
- package/src/billing/dashboard/v2/claim-visits/claim-intervention-details/claim-intervention-panel.component.tsx +184 -0
- package/src/billing/dashboard/v2/claim-visits/claim-intervention-details/intervention-attachments.component.scss +161 -0
- package/src/billing/dashboard/v2/claim-visits/claim-intervention-details/intervention-attachments.component.tsx +328 -0
- package/src/billing/dashboard/v2/claim-visits/claim-invoice-details/claim-invoice-details.component.tsx +96 -0
- package/src/billing/dashboard/v2/claim-visits/claim-invoice-details/claim-invoice-document.component.tsx +236 -0
- package/src/billing/dashboard/v2/claim-visits/claim-invoice-details/claim-invoice-panel.component.scss +98 -0
- package/src/billing/dashboard/v2/claim-visits/claim-invoice-details/claim-invoice-panel.component.tsx +292 -0
- package/src/billing/dashboard/v2/claim-visits/claim-invoice-line-details/claim-invoice-line-details.component.scss +133 -0
- package/src/billing/dashboard/v2/claim-visits/claim-invoice-line-details/claim-invoice-line-details.component.tsx +217 -0
- package/src/billing/dashboard/v2/claim-visits/claim-visit-details/claim-details-by-token.component.tsx +150 -0
- package/src/billing/dashboard/v2/claim-visits/claim-visit-details/claim-details-page.component.scss +13 -0
- package/src/billing/dashboard/v2/claim-visits/claim-visit-details/claim-details-page.component.tsx +116 -0
- package/src/billing/dashboard/v2/claim-visits/claim-visit-details/claim-visit-details.component.scss +338 -0
- package/src/billing/dashboard/v2/claim-visits/claim-visit-details/claim-visit-details.component.tsx +616 -0
- package/src/billing/dashboard/v2/claim-visits/claim-visits.component.scss +5 -0
- package/src/billing/dashboard/v2/claim-visits/claim-visits.component.tsx +133 -0
- package/src/billing/dashboard/v2/claim-visits/modal/claim-doctors/add-claim-doctor/add-claim-doctor.modal.scss +5 -0
- package/src/billing/dashboard/v2/claim-visits/modal/claim-doctors/add-claim-doctor/add-claim-doctor.modal.tsx +49 -0
- package/src/billing/dashboard/v2/claim-visits/modal/claim-visit-details/claim-visit-details.modal.scss +17 -0
- package/src/billing/dashboard/v2/claim-visits/modal/claim-visit-details/claim-visit-details.modal.tsx +56 -0
- package/src/billing/dashboard/v2/claim-visits/modal/close-claim/close-claim.modal.scss +0 -0
- package/src/billing/dashboard/v2/claim-visits/modal/close-claim/close-claim.modal.tsx +129 -0
- package/src/billing/dashboard/v2/claim-visits/modal/submit-claim/submit-claim.modal.tsx +204 -0
- package/src/billing/dashboard/v2/claim-visits/shared/_empty-state.scss +28 -0
- package/src/billing/dashboard/v2/claim-visits/shared/record-cards.component.scss +298 -0
- package/src/billing/dashboard/v2/claim-visits/shared/record-cards.component.tsx +252 -0
- package/src/billing/dashboard/v2/claim-visits/shared/record-details.workspace.scss +42 -0
- package/src/billing/dashboard/v2/claim-visits/shared/record-details.workspace.tsx +54 -0
- package/src/billing/dashboard/v2/claim-visits/shared/record-table.component.scss +61 -0
- package/src/billing/dashboard/v2/claim-visits/shared/record-table.component.tsx +150 -0
- package/src/billing/dashboard/v2/claim-visits/switch-intervention/switch-intervention.resource.ts +51 -0
- package/src/billing/dashboard/v2/claim-visits/switch-intervention/switch-intervention.workspace.scss +191 -0
- package/src/billing/dashboard/v2/claim-visits/switch-intervention/switch-intervention.workspace.tsx +648 -0
- package/src/billing/dashboard/v2/claim-workspace/claim-workspace.component.scss +595 -0
- package/src/billing/dashboard/v2/claim-workspace/claim-workspace.component.tsx +810 -0
- package/src/billing/dashboard/v2/claim-workspace/claim-workspace.resource.ts +282 -0
- package/src/billing/dashboard/v2/claims-accounting/bill-utils.ts +134 -0
- package/src/billing/dashboard/v2/claims-accounting/claim-detail.component.tsx +346 -0
- package/src/billing/dashboard/v2/claims-accounting/claims-accounting.component.scss +546 -0
- package/src/billing/dashboard/v2/claims-accounting/claims-accounting.component.tsx +206 -0
- package/src/billing/dashboard/v2/claims-accounting/claims-accounting.resource.ts +337 -0
- package/src/billing/dashboard/v2/claims-accounting/invoice-document.component.scss +90 -0
- package/src/billing/dashboard/v2/claims-accounting/invoice-document.component.tsx +90 -0
- package/src/billing/dashboard/v2/claims-accounting/remittances.component.tsx +169 -0
- package/src/billing/dashboard/v2/claims-accounting/remittances.resource.ts +46 -0
- package/src/billing/dashboard/v2/claims-accounting/status-meta.ts +25 -0
- package/src/billing/dashboard/v2/clearance/cash-patients.scss +18 -0
- package/src/billing/dashboard/v2/clearance/cash.component.tsx +149 -0
- package/src/billing/dashboard/v2/clearance/clearance.component.scss +84 -0
- package/src/billing/dashboard/v2/clearance/clearance.component.tsx +225 -0
- package/src/billing/dashboard/v2/clearance/pay-cash.component.tsx +176 -0
- package/src/billing/dashboard/v2/clearance/pay-cash.scss +28 -0
- package/src/billing/dashboard/v2/clearance/prepaid-services.component.tsx +112 -0
- package/src/billing/dashboard/v2/facility-bills/claim-status.ts +249 -0
- package/src/billing/dashboard/v2/facility-bills/facility-bills.component.scss +140 -0
- package/src/billing/dashboard/v2/facility-bills/facility-bills.component.tsx +687 -0
- package/src/billing/dashboard/v2/facility-bills/preauths-datatables/pending-preauths.component.tsx +132 -0
- package/src/billing/dashboard/v2/facility-bills/preauths-datatables/preauth-preview-table.component.tsx +267 -0
- package/src/billing/dashboard/v2/facility-bills/preauths.component.tsx +124 -0
- package/src/billing/dashboard/v2/inpatient-requests/inpatient-requests.component.scss +22 -0
- package/src/billing/dashboard/v2/inpatient-requests/inpatient-requests.component.tsx +389 -0
- package/src/billing/dashboard/v2/inpatient-requests/modal/start-inpatient-claim/start-inpatient-claim.component.scss +0 -0
- package/src/billing/dashboard/v2/inpatient-requests/modal/start-inpatient-claim/start-inpatient-claim.component.tsx +0 -0
- package/src/billing/dashboard/v2/new-facility-bills/bills-table.component.tsx +78 -0
- package/src/billing/dashboard/v2/new-facility-bills/bills-table.scss +18 -0
- package/src/billing/dashboard/v2/new-facility-bills/new-facility-bills.component.tsx +64 -0
- package/src/billing/dashboard/v2/new-facility-bills/new-facility-bills.scss +146 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/add-attachments.component.tsx +223 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/attachment.component.tsx +157 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/attachments.scss +92 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/case-summary/case-summary.scss +295 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/case-summary/case-summary.tsx +326 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/dialysis/dialysis-chart.scss +238 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/dialysis/dialysis-chart.tsx +269 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/discharge-summary/discharge-summary.scss +96 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/discharge-summary/discharge-summary.tsx +124 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/final-bill.component.tsx +152 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/final-bill.scss +225 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/general-discharge-summary/general-discharge-summary.scss +182 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/general-discharge-summary/general-discharge-summary.tsx +173 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/generate-attachments.component.tsx +360 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/invoice.component.tsx +151 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/invoice.scss +225 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/type.ts +44 -0
- package/src/billing/dashboard/v2/patient-bill-details/bill-details/bill-details.scss +107 -0
- package/src/billing/dashboard/v2/patient-bill-details/bill-details/bill-details.tsx +508 -0
- package/src/billing/dashboard/v2/patient-bill-details/bill-details-page.component.scss +30 -0
- package/src/billing/dashboard/v2/patient-bill-details/bill-details-page.component.tsx +94 -0
- package/src/billing/dashboard/v2/patient-bill-details/claim-details/claim-details-skeleton.component.scss +89 -0
- package/src/billing/dashboard/v2/patient-bill-details/claim-details/claim-details-skeleton.component.tsx +53 -0
- package/src/billing/dashboard/v2/patient-bill-details/claim-details/patient-claim-details.component.scss +32 -0
- package/src/billing/dashboard/v2/patient-bill-details/claim-details/patient-claim-details.component.tsx +215 -0
- package/src/billing/dashboard/v2/patient-bill-details/modals/add-claim-diagnosis/add-claim-diagnosis.modal.scss +0 -0
- package/src/billing/dashboard/v2/patient-bill-details/modals/add-claim-diagnosis/add-claim-diagnosis.modal.tsx +99 -0
- package/src/billing/dashboard/v2/patient-bill-details/modals/add-claim-line/add-claim-line.modal.tsx +186 -0
- package/src/billing/dashboard/v2/patient-bill-details/patient-bill-details.scss +153 -0
- package/src/billing/dashboard/v2/patient-bill-details/patient-bill-details.tsx +458 -0
- package/src/billing/dashboard/v2/patient-bill-details/payment-mode.ts +124 -0
- package/src/billing/dashboard/v2/patient-bill-details/workspaces/add-claim-line/add-claim-line.workspace.scss +27 -0
- package/src/billing/dashboard/v2/patient-bill-details/workspaces/add-claim-line/add-claim-line.workspace.tsx +222 -0
- package/src/billing/dashboard/v2/patient-bill-details/workspaces/bill-item-payment/bill-item-payment.workspace.scss +27 -0
- package/src/billing/dashboard/v2/patient-bill-details/workspaces/bill-item-payment/bill-item-payment.workspace.tsx +109 -0
- package/src/billing/dashboard/v2/preauth/preauth-attachments.component.tsx +389 -0
- package/src/billing/dashboard/v2/preauth/preauth-list.component.scss +38 -0
- package/src/billing/dashboard/v2/preauth/preauth-list.component.tsx +226 -0
- package/src/billing/dashboard/v2/preauth/preauth-status-tag.component.tsx +75 -0
- package/src/billing/dashboard/v2/preauth/preauth-typed-fields.md +125 -0
- package/src/billing/dashboard/v2/preauth/preauth.resource.ts +1067 -0
- package/src/billing/dashboard/v2/preauth/preauth.workspace.scss +91 -0
- package/src/billing/dashboard/v2/preauth/preauth.workspace.tsx +1802 -0
- package/src/billing/dashboard/v2/preauth/preauthorizations-tab.component.tsx +45 -0
- package/src/billing/dashboard/v2/sha-claims/sha-claims-table.component.tsx +36 -0
- package/src/billing/dashboard/v2/sha-claims/sha-claims.component.tsx +60 -0
- package/src/billing/dashboard/v2/sha-claims/sha-claims.scss +8 -0
- package/src/billing/dashboard/v2/shared/dash-board-card/dash-board-card.component.scss +17 -0
- package/src/billing/dashboard/v2/shared/dash-board-card/dash-board-card.component.tsx +15 -0
- package/src/billing/dashboard/v2/shared/empty-state.component.scss +24 -0
- package/src/billing/dashboard/v2/shared/empty-state.component.tsx +13 -0
- package/src/billing/dashboard/v2/shared/scroll-to-top.component.scss +54 -0
- package/src/billing/dashboard/v2/shared/scroll-to-top.component.tsx +54 -0
- package/src/billing/dashboard/v2/shared/table-toolbar.component.scss +77 -0
- package/src/billing/dashboard/v2/shared/table-toolbar.component.tsx +48 -0
- package/src/billing/dashboard/v2/types/index.ts +507 -0
- package/src/billing/dashboard/v3/active-visits/active-visits.component.tsx +256 -0
- package/src/billing/dashboard/v3/active-visits/active-visits.resource.ts +57 -0
- package/src/billing/dashboard/v3/active-visits/active-visits.scss +15 -0
- package/src/billing/dashboard/v3/cash-checklist/bill-document.component.scss +90 -0
- package/src/billing/dashboard/v3/cash-checklist/bill-document.component.tsx +101 -0
- package/src/billing/dashboard/v3/cash-checklist/cash-checklist.component.scss +199 -0
- package/src/billing/dashboard/v3/cash-checklist/cash-checklist.component.tsx +361 -0
- package/src/billing/dashboard/v3/cash-checklist/cash-checklist.resource.ts +240 -0
- package/src/billing/dashboard/v3/cash-checklist/payment-drawer.component.scss +246 -0
- package/src/billing/dashboard/v3/cash-checklist/payment-drawer.component.tsx +182 -0
- package/src/billing/dashboard/v3/claim-visits/claim-diagnosis-details/claim-diagnosis-details.component.scss +0 -0
- package/src/billing/dashboard/v3/claim-visits/claim-diagnosis-details/claim-diagnosis-details.component.tsx +44 -0
- package/src/billing/dashboard/v3/claim-visits/claim-doctors/claim-doctors.scss +5 -0
- package/src/billing/dashboard/v3/claim-visits/claim-doctors/claim-doctors.tsx +42 -0
- package/src/billing/dashboard/v3/claim-visits/claim-documents/claim-documents.scss +10 -0
- package/src/billing/dashboard/v3/claim-visits/claim-documents/claim-documents.tsx +25 -0
- package/src/billing/dashboard/v3/claim-visits/claim-intervention-details/claim-intervention-details.component.tsx +223 -0
- package/src/billing/dashboard/v3/claim-visits/claim-invoice-details/claim-invoice-details.component.scss +6 -0
- package/src/billing/dashboard/v3/claim-visits/claim-invoice-details/claim-invoice-details.component.tsx +85 -0
- package/src/billing/dashboard/v3/claim-visits/claim-invoice-line-details/claim-invoice-line-details.component.scss +0 -0
- package/src/billing/dashboard/v3/claim-visits/claim-invoice-line-details/claim-invoice-line-details.component.tsx +109 -0
- package/src/billing/dashboard/v3/claim-visits/claim-visit-details/claim-visit-details.component.scss +104 -0
- package/src/billing/dashboard/v3/claim-visits/claim-visit-details/claim-visit-details.component.tsx +336 -0
- package/src/billing/dashboard/v3/claim-visits/claim-visits.component.scss +5 -0
- package/src/billing/dashboard/v3/claim-visits/claim-visits.component.tsx +139 -0
- package/src/billing/dashboard/v3/claim-visits/modal/claim-doctors/add-claim-doctor/add-claim-doctor.modal.scss +5 -0
- package/src/billing/dashboard/v3/claim-visits/modal/claim-doctors/add-claim-doctor/add-claim-doctor.modal.tsx +49 -0
- package/src/billing/dashboard/v3/claim-visits/modal/claim-invoice-lines/claim-invoice-lines.modal.scss +7 -0
- package/src/billing/dashboard/v3/claim-visits/modal/claim-invoice-lines/claim-invoice-lines.modal.tsx +35 -0
- package/src/billing/dashboard/v3/claim-visits/modal/claim-visit-details/claim-visit-details.modal.scss +6 -0
- package/src/billing/dashboard/v3/claim-visits/modal/claim-visit-details/claim-visit-details.modal.tsx +33 -0
- package/src/billing/dashboard/v3/claim-visits/modal/close-claim/close-claim.modal.scss +0 -0
- package/src/billing/dashboard/v3/claim-visits/modal/close-claim/close-claim.modal.tsx +129 -0
- package/src/billing/dashboard/v3/claim-visits/modal/submit-claim/submit-claim.modal.tsx +204 -0
- package/src/billing/dashboard/v3/claim-visits/payer-preview/index.scss +140 -0
- package/src/billing/dashboard/v3/claim-visits/payer-preview/payer-preview-tile.component.tsx +55 -0
- package/src/billing/dashboard/v3/claim-visits/payer-preview/payer-preview-workspace.component.tsx +157 -0
- package/src/billing/dashboard/v3/claim-visits/payer-preview/tables/payer-claim-doctors.component.tsx +54 -0
- package/src/billing/dashboard/v3/claim-visits/payer-preview/tables/payer-claim-lines.component.tsx +48 -0
- package/src/billing/dashboard/v3/claim-visits/payer-preview/tables/payer-claim-notes.component.tsx +47 -0
- package/src/billing/dashboard/v3/claim-visits/payer-preview/tables/payer-diagnoses.component.tsx +44 -0
- package/src/billing/dashboard/v3/claim-visits/payer-preview/tables/payer-interventions.component.tsx +44 -0
- package/src/billing/dashboard/v3/claim-visits/switch-intervention/switch-intervention.resource.ts +51 -0
- package/src/billing/dashboard/v3/claim-visits/switch-intervention/switch-intervention.workspace.scss +191 -0
- package/src/billing/dashboard/v3/claim-visits/switch-intervention/switch-intervention.workspace.tsx +648 -0
- package/src/billing/dashboard/v3/claim-workspace/claim-workspace.component.scss +595 -0
- package/src/billing/dashboard/v3/claim-workspace/claim-workspace.component.tsx +810 -0
- package/src/billing/dashboard/v3/claim-workspace/claim-workspace.resource.ts +282 -0
- package/src/billing/dashboard/v3/claims-accounting/bill-utils.ts +134 -0
- package/src/billing/dashboard/v3/claims-accounting/claim-detail.component.tsx +346 -0
- package/src/billing/dashboard/v3/claims-accounting/claims-accounting.component.scss +546 -0
- package/src/billing/dashboard/v3/claims-accounting/claims-accounting.component.tsx +206 -0
- package/src/billing/dashboard/v3/claims-accounting/claims-accounting.resource.ts +337 -0
- package/src/billing/dashboard/v3/claims-accounting/invoice-document.component.scss +90 -0
- package/src/billing/dashboard/v3/claims-accounting/invoice-document.component.tsx +90 -0
- package/src/billing/dashboard/v3/claims-accounting/remittances.component.tsx +169 -0
- package/src/billing/dashboard/v3/claims-accounting/remittances.resource.ts +46 -0
- package/src/billing/dashboard/v3/claims-accounting/status-meta.ts +25 -0
- package/src/billing/dashboard/v3/clearance/clearance.component.scss +100 -0
- package/src/billing/dashboard/v3/clearance/clearance.component.tsx +0 -0
- package/src/billing/dashboard/v3/clearance/prepaid-services.component.tsx +112 -0
- package/src/billing/dashboard/v3/facility-bills/claim-status.ts +243 -0
- package/src/billing/dashboard/v3/facility-bills/facility-bills.component.scss +9 -0
- package/src/billing/dashboard/v3/facility-bills/facility-bills.component.tsx +172 -0
- package/src/billing/dashboard/v3/facility-bills/preauths-datatables/pending-preauths.component.tsx +132 -0
- package/src/billing/dashboard/v3/facility-bills/preauths-datatables/preauth-preview-table.component.tsx +232 -0
- package/src/billing/dashboard/v3/facility-bills/preauths.component.tsx +124 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/add-attachments.component.tsx +223 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/attachment.component.tsx +157 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/attachments.scss +92 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/case-summary/case-summary-helper.ts +58 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/case-summary/case-summary.scss +295 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/case-summary/case-summary.tsx +273 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/dialysis/dialysis-chart.scss +238 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/dialysis/dialysis-chart.tsx +314 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/discharge-summary/discharge-summary.scss +96 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/discharge-summary/discharge-summary.tsx +126 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/final-bill.component.tsx +75 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/general-discharge-summary/general-discharge-summary.scss +182 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/general-discharge-summary/general-discharge-summary.tsx +253 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/generate-attachments.component.tsx +343 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/invoice.component.tsx +150 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/invoice.scss +225 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/type.ts +259 -0
- package/src/billing/dashboard/v3/patient-bill-details/bill-details/bill-details.scss +13 -0
- package/src/billing/dashboard/v3/patient-bill-details/bill-details/bill-details.tsx +205 -0
- package/src/billing/dashboard/v3/patient-bill-details/claim-details/patient-claim-details.component.scss +0 -0
- package/src/billing/dashboard/v3/patient-bill-details/claim-details/patient-claim-details.component.tsx +61 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/add-claim-diagnosis/add-claim-diagnosis.modal.scss +0 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/add-claim-diagnosis/add-claim-diagnosis.modal.tsx +99 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/add-claim-line/add-claim-line.modal.scss +14 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/add-claim-line/add-claim-line.modal.tsx +111 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/bill-item-payment/bill-item-payment.modal.scss +6 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/bill-item-payment/bill-item-payment.modal.tsx +139 -0
- package/src/billing/dashboard/v3/patient-bill-details/patient-bill-details.scss +20 -0
- package/src/billing/dashboard/v3/patient-bill-details/patient-bill-details.tsx +254 -0
- package/src/billing/dashboard/v3/patient-bill-details/visit-diagnosis-details/visit-diagnosis-details.component.scss +0 -0
- package/src/billing/dashboard/v3/patient-bill-details/visit-diagnosis-details/visit-diagnosis-details.component.tsx +80 -0
- package/src/billing/dashboard/v3/preauth/preauth-attachments.component.tsx +389 -0
- package/src/billing/dashboard/v3/preauth/preauth-list.component.scss +34 -0
- package/src/billing/dashboard/v3/preauth/preauth-list.component.tsx +281 -0
- package/src/billing/dashboard/v3/preauth/preauth-status-tag.component.tsx +75 -0
- package/src/billing/dashboard/v3/preauth/preauth-typed-fields.md +125 -0
- package/src/billing/dashboard/v3/preauth/preauth.resource.ts +1072 -0
- package/src/billing/dashboard/v3/preauth/preauth.workspace.scss +91 -0
- package/src/billing/dashboard/v3/preauth/preauth.workspace.tsx +1806 -0
- package/src/billing/dashboard/v3/preauth/preauthorizations-tab.component.tsx +45 -0
- package/src/billing/dashboard/v3/shared/empty-state.component.scss +25 -0
- package/src/billing/dashboard/v3/shared/empty-state.component.tsx +13 -0
- package/src/billing/dashboard/v3/shared/table-toolbar.component.scss +64 -0
- package/src/billing/dashboard/v3/shared/table-toolbar.component.tsx +48 -0
- package/src/billing/dashboard/v3/types/index.ts +381 -0
- package/src/billing/extensions/generate-order-bill-button/generate-order-bill-button.extension.tsx +55 -0
- package/src/billing/extensions/generate-order-bill-button/generate-order-bill-button.scss +16 -0
- package/src/billing/extensions/visit-billing/visit-billing.extension.scss +0 -0
- package/src/billing/extensions/visit-billing/visit-billing.extension.tsx +509 -0
- package/src/billing/invoice/bill.resource.ts +47 -0
- package/src/billing/invoice/invoice-header/header-card/header-card.scss +17 -0
- package/src/billing/invoice/invoice-header/header-card/header-card.tsx +21 -0
- package/src/billing/invoice/invoice.scss +113 -0
- package/src/billing/invoice/invoice.tsx +1441 -0
- package/src/billing/invoice/line-items/line-items.scss +0 -0
- package/src/billing/invoice/line-items/line-items.tsx +120 -0
- package/src/billing/invoice/modal/delete-bill-item/delete-bill-item.modal.scss +23 -0
- package/src/billing/invoice/modal/delete-bill-item/delete-bill-item.modal.tsx +114 -0
- package/src/billing/invoice/modal/edit-bill-item/edit-bill-item.modal.scss +0 -0
- package/src/billing/invoice/modal/edit-bill-item/edit-bill-item.modal.tsx +122 -0
- package/src/billing/invoice/payment-details/payment-details.scss +0 -0
- package/src/billing/invoice/payment-details/payment-details.tsx +43 -0
- package/src/billing/invoice/print-invoice/print-receipt.component.tsx +44 -0
- package/src/billing/invoice/print-invoice/print-receipt.scss +14 -0
- package/src/billing/maternity-discharge.resource.ts +21 -0
- package/src/billing/types/index.ts +354 -0
- package/src/billing/utils/index.ts +17 -0
- package/src/billing/widgets/billingTotalsRow.component.scss +0 -0
- package/src/billing/widgets/billingTotalsRow.component.tsx +712 -0
- package/src/billing/workspaces/create-order-bill-form-workspace/create-order-bill-form.resource.ts +130 -0
- package/src/billing/workspaces/create-order-bill-form-workspace/create-order-bill-form.scss +58 -0
- package/src/billing/workspaces/create-order-bill-form-workspace/create-order-bill-form.workspace.tsx +645 -0
- package/src/billing/workspaces/create-order-bill-form-workspace/schema.ts +12 -0
- package/src/bookings/bookings.component.scss +7 -0
- package/src/bookings/bookings.component.tsx +35 -0
- package/src/bookings/daily/daily-bookings.resource.ts +2 -1
- package/src/case-summary/case-summary.extension.scss +13 -0
- package/src/case-summary/case-summary.extension.tsx +40 -0
- package/src/case-summary/case-summary.resource.test.ts +69 -0
- package/src/case-summary/case-summary.resource.ts +52 -0
- package/src/case-summary/components/case-summary-printable.component.scss +174 -0
- package/src/case-summary/components/case-summary-printable.component.tsx +288 -0
- package/src/case-summary/components/case-summary-printable.utils.ts +51 -0
- package/src/case-summary/types/case-summary.types.ts +152 -0
- package/src/claims/claims.component.scss +70 -0
- package/src/claims/claims.component.tsx +713 -0
- package/src/claims/claims.resource.ts +1274 -0
- package/src/claims/index.ts +340 -0
- package/src/claims/interventions.resource.ts +131 -0
- package/src/claims/utils.ts +64 -0
- package/src/config-schema.ts +114 -1
- package/src/context/patient-context.tsx +27 -0
- package/src/createDashboardLink.tsx +9 -0
- package/src/dashboard/charts/chart.component.scss +24 -0
- package/src/dashboard/charts/chart.component.tsx +56 -0
- package/src/dashboard/dashboard.component.scss +48 -3
- package/src/dashboard/dashboard.component.tsx +26 -36
- package/src/dashboard/overview/overview.component.scss +40 -59
- package/src/dashboard/overview/overview.component.tsx +53 -41
- package/src/dashboard-meta/accounting-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/admissions-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/billing-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/bookings-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/case-summary.meta.ts +6 -0
- package/src/dashboard-meta/consultation-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/dha-workflow-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/inpatient-admissions.meta.ts +6 -0
- package/src/dashboard-meta/maternity-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/mch-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/pharmacy-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/queue-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/registers-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/registry-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/service-queue-admin.meta.ts +6 -0
- package/src/dashboard-meta/specialized-clinics-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/triage-dashboard.meta.ts +6 -0
- package/src/index.ts +177 -6
- package/src/mnch/maternity/maternity-queues.component.scss +7 -0
- package/src/mnch/maternity/maternity-queues.component.tsx +32 -0
- package/src/mnch/maternity/queues/triage/maternity-triage.tsx +15 -0
- package/src/mnch/mch/mch-queues.component.scss +10 -0
- package/src/mnch/mch/mch-queues.component.tsx +36 -0
- package/src/mnch/mch/queues/consultation/mch-consultation.tsx +18 -0
- package/src/mnch/mch/queues/triage/mch-triage.tsx +15 -0
- package/src/mnch/mnch-root.tsx +17 -0
- package/src/mortuary/mortuary.component.tsx +13 -0
- package/src/pharmacy/pharmacy.component.scss +16 -0
- package/src/pharmacy/pharmacy.component.tsx +11 -6
- package/src/registers/registers.component.tsx +8 -0
- package/src/registry/drawer/emr-compare.component.scss +263 -0
- package/src/registry/drawer/emr-compare.component.tsx +302 -0
- package/src/registry/drawer/emr-compare.resource.ts +181 -0
- package/src/registry/drawer/emr-create-preview.component.tsx +123 -0
- package/src/registry/drawer/otp-verification-step.component.tsx +398 -0
- package/src/registry/drawer/pomsf-balance.util.test.ts +177 -0
- package/src/registry/drawer/pomsf-balance.util.ts +79 -0
- package/src/registry/drawer/verification.resource.ts +60 -0
- package/src/registry/drawer/workflow-drawer.component.scss +1242 -0
- package/src/registry/drawer/workflow-drawer.component.tsx +1476 -0
- package/src/registry/eligibility/eligibility-details/eligibility-details.scss +38 -0
- package/src/registry/eligibility/eligibility-details/eligibility-details.tsx +101 -0
- package/src/registry/eligibility/eliigibility-tags/eligibility-tags.scss +16 -0
- package/src/registry/eligibility/eliigibility-tags/eligibility-tags.tsx +120 -0
- package/src/registry/eligibility/modal/eligibility-details.modal.scss +0 -0
- package/src/registry/eligibility/modal/eligibility-details.modal.tsx +45 -0
- package/src/registry/hie.resource.ts +408 -0
- package/src/registry/hie.types.ts +57 -0
- package/src/registry/modal/biometrics-verification-modal/biometrics-verification-modal.scss +277 -0
- package/src/registry/modal/biometrics-verification-modal/biometrics-verification-modal.tsx +218 -0
- package/src/registry/modal/biometrics-verification-modal/type.ts +39 -0
- package/src/registry/modal/client-details-modal/client-details-modal.tsx +65 -29
- package/src/registry/modal/otp-modal/otp-whitlisting-modal.component.tsx +815 -0
- package/src/registry/modal/otp-modal/otp-whitlisting-modal.scss +354 -0
- package/src/registry/modal/otp-modal/otp-whitlisting.scss +0 -0
- package/src/registry/modal/otp-verification-modal/claims-consent.scss +72 -0
- package/src/registry/modal/otp-verification-modal/claims-consent.tsx +135 -0
- package/src/registry/modal/otp-verification-modal/extension/claims-consent.extension.tsx +124 -0
- package/src/registry/modal/otp-verification-modal/otp-verification-modal.scss +30 -0
- package/src/registry/modal/otp-verification-modal/otp-verification-modal.tsx +154 -54
- package/src/registry/modal/send-to-triage/payment-details.tsx +120 -0
- package/src/registry/modal/send-to-triage/payment-method.component.tsx +54 -0
- package/src/registry/modal/send-to-triage/send-to-queue.modal.tsx +980 -0
- package/src/registry/modal/send-to-triage/send-to-triage.modal.scss +156 -3
- package/src/registry/modal/send-to-triage/send-to-triage.modal.tsx +1101 -131
- package/src/registry/modal/start-patient-visit/start-patient-visit.modal.scss +34 -0
- package/src/registry/modal/start-patient-visit/start-patient-visit.modal.tsx +231 -0
- package/src/registry/payment-details/payment-options/payment-options.scss +13 -0
- package/src/registry/payment-details/payment-options/payment-options.tsx +61 -14
- package/src/registry/registration-list/registration-list.component.scss +32 -0
- package/src/registry/registration-list/registration-list.component.tsx +103 -0
- package/src/registry/registry-entry.tsx +11 -0
- package/src/registry/registry.component.scss +402 -78
- package/src/registry/registry.component.tsx +547 -221
- package/src/registry/registry.resource.ts +22 -3
- package/src/registry/types/index.ts +117 -8
- package/src/registry/utils/error-handler.ts +54 -0
- package/src/registry/utils/format-dependant-display-data.ts +1 -1
- package/src/registry/utils/hie-client-adapter.ts +6 -3
- package/src/registry/utils/mask-data.ts +40 -0
- package/src/registry/utils/phone-number-formatter.ts +11 -0
- package/src/resources/dashboard.resource.ts +20 -0
- package/src/resources/identifier-types.ts +2 -0
- package/src/resources/patient-resource.ts +6 -1
- package/src/resources/queue.resource.ts +24 -1
- package/src/resources/superset.resource.ts +21 -0
- package/src/resources/visit.resource.ts +19 -1
- package/src/root.component.tsx +8 -5
- package/src/routes.json +417 -23
- package/src/service-queues/admin/queue/modal/create-queue/create-queue.modal.scss +31 -0
- package/src/service-queues/admin/queue/modal/create-queue/create-queue.modal.tsx +153 -0
- package/src/service-queues/admin/queue/modal/edit-queue/edit-queue.modal.scss +0 -0
- package/src/service-queues/admin/queue/modal/edit-queue/edit-queue.modal.tsx +182 -0
- package/src/service-queues/admin/queue/queue-list/queue-list.scss +33 -0
- package/src/service-queues/admin/queue/queue-list/queue-list.tsx +113 -0
- package/src/service-queues/admin/queue-entry/queue-entry-list.component.scss +6 -0
- package/src/service-queues/admin/queue-entry/queue-entry-list.component.tsx +137 -0
- package/src/service-queues/admin/queue-room/modal/create-queue-room/create-queue-room.modal.scss +31 -0
- package/src/service-queues/admin/queue-room/modal/create-queue-room/create-queue-room.modal.tsx +137 -0
- package/src/service-queues/admin/queue-room/modal/edit-queue-room/edit-queue-room.modal.scss +0 -0
- package/src/service-queues/admin/queue-room/modal/edit-queue-room/edit-queue-room.modal.tsx +146 -0
- package/src/service-queues/admin/queue-room/queue-room-list/queue-room-list.scss +22 -0
- package/src/service-queues/admin/queue-room/queue-room-list/queue-room-list.tsx +120 -0
- package/src/service-queues/admin/service-queue-admin-dashboard.component.scss +6 -0
- package/src/service-queues/admin/service-queue-admin-dashboard.component.tsx +34 -0
- package/src/service-queues/consultation/consultation.component.tsx +9 -0
- package/src/service-queues/extensions/service-queue-patient-banner/service-queue-patient-banner.scss +30 -0
- package/src/service-queues/extensions/service-queue-patient-banner/service-queue-patient-banner.tsx +108 -0
- package/src/service-queues/modals/daily-report-patient-list/daily-report-patient-list.scss +26 -0
- package/src/service-queues/modals/daily-report-patient-list/daily-report-patient-list.tsx +110 -0
- package/src/service-queues/modals/move/move-patient.component.scss +1 -1
- package/src/service-queues/modals/move/move-patient.component.tsx +31 -17
- package/src/service-queues/queue-list/check-in.service.ts +26 -0
- package/src/service-queues/queue-list/queue-list.component.scss +37 -0
- package/src/service-queues/queue-list/queue-list.component.tsx +256 -56
- package/src/service-queues/service-queue/service-queue.component.tsx +151 -8
- package/src/service-queues/service-queue/stats/stat-details/stat-details.component.scss +5 -0
- package/src/service-queues/service-queue/stats/stat-details/stat-details.component.tsx +36 -7
- package/src/service-queues/service-queue.tsx +22 -16
- package/src/service-queues/service-queues.resource.ts +197 -1
- package/src/service-queues/service.resource.ts +1 -1
- package/src/shared/constants/concepts.ts +50 -0
- package/src/shared/constants/patient-category.ts +6 -0
- package/src/shared/constants/patient-type.ts +10 -0
- package/src/shared/constants/visit-types.ts +7 -0
- package/src/shared/services/billing.resource.ts +75 -0
- package/src/shared/services/claims.resource.ts +47 -0
- package/src/shared/services/client-payment-mode.resource.ts +27 -0
- package/src/shared/services/client-payment.resource.ts +17 -0
- package/src/shared/services/consultation-clearance.resource.ts +210 -0
- package/src/shared/services/eligibility.resource.ts +20 -0
- package/src/shared/services/encounters.resource.ts +33 -0
- package/src/shared/services/location.resource.ts +9 -0
- package/src/shared/types/index.ts +156 -0
- package/src/shared/ui/aggregate-stat-card/aggregate-stat-card.scss +42 -0
- package/src/shared/ui/aggregate-stat-card/aggregate-stat-card.tsx +42 -0
- package/src/shared/ui/confirm-modal/confirm.modal.scss +18 -0
- package/src/shared/ui/confirm-modal/confirm.modal.tsx +38 -0
- package/src/shared/ui/facility-worker-slot/facility-worker.component-slot.component.scss +39 -0
- package/src/shared/ui/facility-worker-slot/facility-worker.component-slot.component.tsx +19 -0
- package/src/shared/ui/otp-input/otp-input.component.scss +14 -0
- package/src/shared/ui/otp-input/otp-input.component.tsx +97 -0
- package/src/{service-queues/service-queue/stats → shared/ui}/stat-card/stat-card.component.tsx +6 -3
- package/src/shared/ui/timer/timer.component.scss +5 -0
- package/src/shared/ui/timer/timer.component.tsx +40 -0
- package/src/shared/utils/get-base-url.ts +10 -0
- package/src/shared/utils/get-tag-type.ts +75 -0
- package/src/side-nav-menu/mnch-nav-link-config.ts +16 -0
- package/src/side-nav-menu/mnch-nav-links.tsx +42 -0
- package/src/side-nav-menu/nav-link-config.ts +1 -5
- package/src/side-nav-menu/specialized-clinics-nav-link-config.ts +36 -0
- package/src/side-nav-menu/specialized-clinics-nav-links.tsx +42 -0
- package/src/specialized-clinics/critital-care-unit/critical-care-unit-queues.component.scss +7 -0
- package/src/specialized-clinics/critital-care-unit/critical-care-unit-queues.component.tsx +36 -0
- package/src/specialized-clinics/critital-care-unit/queues/consultation/critical-care-unit-consultation.tsx +15 -0
- package/src/specialized-clinics/critital-care-unit/queues/triage/critical-care-unit-triage.tsx +15 -0
- package/src/specialized-clinics/dental/dental-queues.component.scss +7 -0
- package/src/specialized-clinics/dental/dental-queues.component.tsx +36 -0
- package/src/specialized-clinics/dental/queues/consultation/dental-consultation.tsx +15 -0
- package/src/specialized-clinics/dental/queues/triage/dental-triage.tsx +15 -0
- package/src/specialized-clinics/diagnostic-and-imaging/diagnostic-and-imaging.component.scss +7 -0
- package/src/specialized-clinics/diagnostic-and-imaging/diagnostic-and-imaging.component.tsx +36 -0
- package/src/specialized-clinics/diagnostic-and-imaging/queues/consultation/diagnosis-and-imaging-consultation.tsx +15 -0
- package/src/specialized-clinics/diagnostic-and-imaging/queues/triage/diagnosis-and-imaging-triage.tsx +15 -0
- package/src/specialized-clinics/oncology/oncology-queues.component.scss +7 -0
- package/src/specialized-clinics/oncology/oncology-queues.component.tsx +36 -0
- package/src/specialized-clinics/oncology/queues/consultation/oncology-consultation.tsx +15 -0
- package/src/specialized-clinics/oncology/queues/triage/oncology-triage.tsx +15 -0
- package/src/specialized-clinics/ophthalmology/ophthalmology-queues.component.scss +7 -0
- package/src/specialized-clinics/ophthalmology/ophthalmology-queues.component.tsx +36 -0
- package/src/specialized-clinics/ophthalmology/queues/consultation/ophthalmology-consultation.tsx +15 -0
- package/src/specialized-clinics/ophthalmology/queues/triage/ophthalmology-triage.tsx +15 -0
- package/src/specialized-clinics/psychiatry/psychiatry-queues.component.scss +7 -0
- package/src/specialized-clinics/psychiatry/psychiatry-queues.component.tsx +36 -0
- package/src/specialized-clinics/psychiatry/queues/consultation/psychiatry-consultation.tsx +15 -0
- package/src/specialized-clinics/psychiatry/queues/triage/psychiatry-triage.tsx +15 -0
- package/src/specialized-clinics/renal/queues/consultation/dialysis-consultation.tsx +15 -0
- package/src/specialized-clinics/renal/queues/triage/renal-triage.tsx +15 -0
- package/src/specialized-clinics/renal/renal-queues.component.scss +7 -0
- package/src/specialized-clinics/renal/renal-queues.component.tsx +36 -0
- package/src/specialized-clinics/specialized-clinics-root.tsx +27 -0
- package/src/triage/triage.component.scss +6 -0
- package/src/triage/triage.component.tsx +4 -0
- package/src/types/types.ts +56 -1
- package/webpack.config.js +54 -1
- package/dist/104.js +0 -2
- package/dist/104.js.map +0 -1
- package/dist/15.js +0 -1
- package/dist/15.js.map +0 -1
- package/dist/184.js +0 -2
- package/dist/184.js.map +0 -1
- package/dist/197.js +0 -1
- package/dist/255.js +0 -1
- package/dist/255.js.map +0 -1
- package/dist/300.js +0 -1
- package/dist/335.js +0 -1
- package/dist/339.js +0 -1
- package/dist/339.js.map +0 -1
- package/dist/353.js +0 -1
- package/dist/353.js.map +0 -1
- package/dist/420.js +0 -1
- package/dist/420.js.map +0 -1
- package/dist/540.js +0 -2
- package/dist/540.js.map +0 -1
- package/dist/55.js +0 -1
- package/dist/652.js +0 -1
- package/dist/709.js +0 -1
- package/dist/709.js.map +0 -1
- package/dist/710.js +0 -2
- package/dist/710.js.map +0 -1
- package/dist/729.js +0 -1
- package/dist/729.js.map +0 -1
- package/dist/752.js +0 -1
- package/dist/752.js.map +0 -1
- package/dist/833.js +0 -1
- package/dist/833.js.map +0 -1
- package/dist/907.js +0 -1
- package/dist/907.js.map +0 -1
- package/dist/91.js +0 -1
- package/dist/91.js.map +0 -1
- package/dist/93.js +0 -1
- package/dist/93.js.map +0 -1
- package/dist/943.js +0 -1
- package/dist/943.js.map +0 -1
- package/dist/99.js +0 -1
- /package/dist/{104.js.LICENSE.txt → 2177.js.LICENSE.txt} +0 -0
- /package/dist/{810.js.LICENSE.txt → 262.js.LICENSE.txt} +0 -0
- /package/dist/{184.js.LICENSE.txt → 3184.js.LICENSE.txt} +0 -0
- /package/dist/{540.js.LICENSE.txt → 6540.js.LICENSE.txt} +0 -0
- /package/dist/{710.js.LICENSE.txt → 7830.js.LICENSE.txt} +0 -0
- /package/src/{service-queues/service-queue/stats → shared/ui}/stat-card/stat-card.component.scss +0 -0
|
@@ -0,0 +1,1274 @@
|
|
|
1
|
+
import useSWR, { mutate as globalMutate } from 'swr';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import {
|
|
4
|
+
ServiceType,
|
|
5
|
+
type BenefitUtilization,
|
|
6
|
+
type InterventionResults,
|
|
7
|
+
type ClaimResult,
|
|
8
|
+
type Intervention,
|
|
9
|
+
VisitType,
|
|
10
|
+
type ClientSubBenefit,
|
|
11
|
+
PomsfBalance,
|
|
12
|
+
PreExistingIntervention,
|
|
13
|
+
PreauthRequest,
|
|
14
|
+
} from './index';
|
|
15
|
+
import { fetchUrl, getHieBaseUrl, getUrl, useHie } from './utils';
|
|
16
|
+
import { openmrsFetch, restBaseUrl, useSession, Visit } from '@openmrs/esm-framework';
|
|
17
|
+
|
|
18
|
+
export const useClientSubBenefits = (clientRegistryId: string) => {
|
|
19
|
+
const { hieBaseUrl, locationUuid } = useHie();
|
|
20
|
+
const url = clientRegistryId
|
|
21
|
+
? `${hieBaseUrl}/sub-benefits?patient_id=${clientRegistryId}&locationUuid=${locationUuid}`
|
|
22
|
+
: null;
|
|
23
|
+
|
|
24
|
+
const { data, error, isLoading } = useSWR<{ data: Array<ClientSubBenefit> }>(url, openmrsFetch);
|
|
25
|
+
|
|
26
|
+
const results = data?.data;
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
clientSubBenefits: results,
|
|
30
|
+
error,
|
|
31
|
+
isLoadingClientSubBenefits: isLoading,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const useInterventions = (clientRegistryId: string, subBenefitCode: string) => {
|
|
36
|
+
const { hieBaseUrl, locationUuid } = useHie();
|
|
37
|
+
const url =
|
|
38
|
+
clientRegistryId && subBenefitCode
|
|
39
|
+
? `${hieBaseUrl}/interventions?patient_id=${clientRegistryId}&locationUuid=${locationUuid}&sub_benefit_code=${subBenefitCode}`
|
|
40
|
+
: null;
|
|
41
|
+
|
|
42
|
+
const { data, error, isLoading } = useSWR<{ data: Array<Intervention> }>(url, openmrsFetch);
|
|
43
|
+
|
|
44
|
+
const results = data?.data;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
interventions: results,
|
|
48
|
+
error,
|
|
49
|
+
isLoadingInterventions: isLoading,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Fetch patient sub-benefits (required by hie-saf interventions proxy).
|
|
55
|
+
*/
|
|
56
|
+
export async function fetchClientSubBenefits(
|
|
57
|
+
patientId: string,
|
|
58
|
+
locationUuid: string,
|
|
59
|
+
): Promise<ClientSubBenefit[]> {
|
|
60
|
+
if (!patientId || !locationUuid) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
64
|
+
const params = new URLSearchParams({
|
|
65
|
+
patient_id: patientId,
|
|
66
|
+
locationUuid,
|
|
67
|
+
});
|
|
68
|
+
const response = await openmrsFetch(`${hieBaseUrl}/sub-benefits?${params.toString()}`);
|
|
69
|
+
const data = response?.data;
|
|
70
|
+
if (Array.isArray(data)) {
|
|
71
|
+
return data;
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(data?.results)) {
|
|
74
|
+
return data.results;
|
|
75
|
+
}
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function unwrapInterventions(data: unknown): Intervention[] {
|
|
80
|
+
if (Array.isArray(data)) {
|
|
81
|
+
return data as Intervention[];
|
|
82
|
+
}
|
|
83
|
+
if (data && typeof data === 'object' && Array.isArray((data as { results?: unknown }).results)) {
|
|
84
|
+
return (data as { results: Intervention[] }).results;
|
|
85
|
+
}
|
|
86
|
+
if (data && typeof data === 'object' && 'code' in (data as object)) {
|
|
87
|
+
return [data as Intervention];
|
|
88
|
+
}
|
|
89
|
+
return [];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** Parent package prefix from an intervention code, e.g. SHA-19-239 → SHA-19 */
|
|
93
|
+
function interventionPackagePrefix(interventionCode: string): string {
|
|
94
|
+
const parts = interventionCode.trim().toUpperCase().split('-');
|
|
95
|
+
if (parts.length >= 2) {
|
|
96
|
+
return `${parts[0]}-${parts[1]}`;
|
|
97
|
+
}
|
|
98
|
+
return interventionCode.trim().toUpperCase();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Look up a single SHA intervention by code via interventions coverage.
|
|
103
|
+
* hie-saf requires `sub_benefit_code`; we resolve it from the patient's sub-benefits,
|
|
104
|
+
* preferring packages that match the intervention prefix (SHA-19-239 → SHA-19…).
|
|
105
|
+
* Response includes `needsPreauth` / `needsManualPreauthApproval`.
|
|
106
|
+
* @see https://hie-docs.dha.go.ke/docs/claims/process/preauths/normalPreauths
|
|
107
|
+
*/
|
|
108
|
+
export async function fetchShaInterventionByCode(
|
|
109
|
+
patientId: string,
|
|
110
|
+
locationUuid: string,
|
|
111
|
+
interventionCode: string,
|
|
112
|
+
subBenefitCode?: string,
|
|
113
|
+
): Promise<Intervention | null> {
|
|
114
|
+
if (!patientId || !locationUuid || !interventionCode) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
118
|
+
const code = interventionCode.trim().toUpperCase();
|
|
119
|
+
const prefix = interventionPackagePrefix(code);
|
|
120
|
+
|
|
121
|
+
const tryFetch = async (sbCode: string): Promise<Intervention | null> => {
|
|
122
|
+
if (!sbCode) return null;
|
|
123
|
+
const params = new URLSearchParams({
|
|
124
|
+
patient_id: patientId,
|
|
125
|
+
locationUuid,
|
|
126
|
+
sub_benefit_code: sbCode,
|
|
127
|
+
code: interventionCode.trim(),
|
|
128
|
+
});
|
|
129
|
+
const response = await openmrsFetch(`${hieBaseUrl}/interventions?${params.toString()}`);
|
|
130
|
+
const list = unwrapInterventions(response?.data);
|
|
131
|
+
return list.find((i) => (i?.code ?? '').trim().toUpperCase() === code) ?? null;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
if (subBenefitCode) {
|
|
135
|
+
const hit = await tryFetch(subBenefitCode);
|
|
136
|
+
if (hit) return hit;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const subBenefits = await fetchClientSubBenefits(patientId, locationUuid);
|
|
140
|
+
if (subBenefits.length === 0) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const ranked = [...subBenefits].sort((a, b) => {
|
|
145
|
+
const score = (s: ClientSubBenefit) => {
|
|
146
|
+
const c = (s.code ?? '').toUpperCase();
|
|
147
|
+
const parent = (s.parentBenefitCode ?? '').toUpperCase();
|
|
148
|
+
if (c === prefix || parent === prefix) return 0;
|
|
149
|
+
if (c.startsWith(`${prefix}-`) || c.startsWith(prefix)) return 1;
|
|
150
|
+
return 2;
|
|
151
|
+
};
|
|
152
|
+
return score(a) - score(b);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
for (const sb of ranked) {
|
|
156
|
+
try {
|
|
157
|
+
const hit = await tryFetch(sb.code);
|
|
158
|
+
if (hit) return hit;
|
|
159
|
+
} catch {
|
|
160
|
+
// try next sub-benefit
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export const useBenefitUtilizations = (clientRegistryId: string, interventionCode: string, isCapitation: boolean, isPomsf: boolean) => {
|
|
167
|
+
const { hieBaseUrl, locationUuid } = useHie();
|
|
168
|
+
const url =
|
|
169
|
+
clientRegistryId && interventionCode && !isCapitation && !isPomsf
|
|
170
|
+
? `${hieBaseUrl}/benefits-utilization?patient_id=${clientRegistryId}&locationUuid=${locationUuid}&intervention_code=${interventionCode}`
|
|
171
|
+
: null;
|
|
172
|
+
|
|
173
|
+
const { data, error, isLoading } = useSWR<{ data: Array<BenefitUtilization> }>(url, openmrsFetch);
|
|
174
|
+
|
|
175
|
+
const results = data?.data;
|
|
176
|
+
|
|
177
|
+
if (results && 'error' in results && 'message' in results) {
|
|
178
|
+
return {
|
|
179
|
+
benefitUtilizations: null,
|
|
180
|
+
error,
|
|
181
|
+
isLoadingClientSubBenefits: isLoading,
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
benefitUtilizations: results,
|
|
187
|
+
error,
|
|
188
|
+
isLoadingBenefitUtilization: isLoading,
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export const usePomsfBalance = (clientRegistryId: string, isPomsf: boolean) => {
|
|
193
|
+
const { hieBaseUrl, locationUuid } = useHie();
|
|
194
|
+
const url =
|
|
195
|
+
clientRegistryId && isPomsf
|
|
196
|
+
? `${hieBaseUrl}/pomsf-balance?patient_id=${clientRegistryId}&locationUuid=${locationUuid}`
|
|
197
|
+
: null;
|
|
198
|
+
|
|
199
|
+
const { data, error, isLoading } = useSWR<{ data: PomsfBalance }>(url, openmrsFetch);
|
|
200
|
+
|
|
201
|
+
const results = data?.data;
|
|
202
|
+
|
|
203
|
+
if (results && 'error' in results && 'message' in results) {
|
|
204
|
+
return {
|
|
205
|
+
pomsfBalance: null,
|
|
206
|
+
error,
|
|
207
|
+
isLoadingPomsfBalances: isLoading,
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return {
|
|
212
|
+
pomsfBalance: results,
|
|
213
|
+
error,
|
|
214
|
+
isLoadingPomsfBalances: isLoading,
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
// Promise-based counterpart to usePomsfBalance, for callers that already run
|
|
219
|
+
// their own useEffect (e.g. components inside this same module, which don't
|
|
220
|
+
// need useHie's useConfig({ externalModuleName }) lookup — that path has been
|
|
221
|
+
// observed to throw React error #310 when invoked from certain call sites).
|
|
222
|
+
export async function fetchPomsfBalance(clientRegistryId: string, locationUuid: string): Promise<PomsfBalance | null> {
|
|
223
|
+
if (!clientRegistryId || !locationUuid) {
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
227
|
+
const url = `${hieBaseUrl}/pomsf-balance?patient_id=${clientRegistryId}&locationUuid=${locationUuid}`;
|
|
228
|
+
const response = await openmrsFetch<PomsfBalance>(url);
|
|
229
|
+
const results = response?.data;
|
|
230
|
+
|
|
231
|
+
if (results && 'error' in results && 'message' in results) {
|
|
232
|
+
return null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return results ?? null;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export async function createClaimsVisit(
|
|
239
|
+
interventionCode: string,
|
|
240
|
+
crIdentifier: string,
|
|
241
|
+
serviceType: ServiceType,
|
|
242
|
+
locationUuid: string,
|
|
243
|
+
{ auth_guid, otp }: { auth_guid?: string; otp?: string } = {},
|
|
244
|
+
) {
|
|
245
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
246
|
+
const url = `${hieBaseUrl}/claims-visit`;
|
|
247
|
+
|
|
248
|
+
let payload = {
|
|
249
|
+
locationUuid,
|
|
250
|
+
intervention_codes: [interventionCode],
|
|
251
|
+
patient_id: crIdentifier,
|
|
252
|
+
service_type: serviceType, // Type of service Options: CAPITATION, OUTPATIENT, INPATIENT, EMERGENCY
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
if (otp) {
|
|
256
|
+
payload['otp'] = otp;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (auth_guid) {
|
|
260
|
+
payload['auth_guid'] = auth_guid;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
const result = await openmrsFetch<ClaimResult>(url, {
|
|
264
|
+
method: 'POST',
|
|
265
|
+
headers: {
|
|
266
|
+
'Content-Type': 'application/json',
|
|
267
|
+
},
|
|
268
|
+
// signal: abortController.signal,
|
|
269
|
+
body: payload,
|
|
270
|
+
}).catch((error) => {
|
|
271
|
+
const message = error?.responseBody?.message ?? '';
|
|
272
|
+
if (typeof message === 'object') {
|
|
273
|
+
throw `${message?.join(',')}`;
|
|
274
|
+
}
|
|
275
|
+
throw message;
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
if (result?.data && 'error' in result.data && 'message' in result.data) {
|
|
279
|
+
const message = result.data.message ?? '';
|
|
280
|
+
throw message;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return result.data;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export const usePreExistingIntervention = (patientUuid: string) => {
|
|
287
|
+
const { hieBaseUrl } = useHie();
|
|
288
|
+
const url = patientUuid
|
|
289
|
+
? `${hieBaseUrl}/bill-order/patient-claim-bill-order?patient_uuid=${patientUuid}`
|
|
290
|
+
: null;
|
|
291
|
+
|
|
292
|
+
const { data, error, isLoading } = useSWR<{ data: PreExistingIntervention[] }>(url, openmrsFetch);
|
|
293
|
+
|
|
294
|
+
const results = data?.data;
|
|
295
|
+
|
|
296
|
+
return {
|
|
297
|
+
preExistingInterventions: results,
|
|
298
|
+
error,
|
|
299
|
+
isLoadingPreExistingIntervention: isLoading,
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
export async function updateBillOrderConsentToken(
|
|
304
|
+
id: number,
|
|
305
|
+
consentToken: string,
|
|
306
|
+
) {
|
|
307
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
308
|
+
const url = `${hieBaseUrl}/bill-order/${id}/consent-token`;
|
|
309
|
+
|
|
310
|
+
let payload = {
|
|
311
|
+
consent_token: consentToken
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
const result = await openmrsFetch<any>(url, {
|
|
315
|
+
method: 'PATCH',
|
|
316
|
+
headers: {
|
|
317
|
+
'Content-Type': 'application/json',
|
|
318
|
+
},
|
|
319
|
+
body: payload,
|
|
320
|
+
}).catch((error) => {
|
|
321
|
+
const message = error?.responseBody?.message ?? '';
|
|
322
|
+
if (typeof message === 'object') {
|
|
323
|
+
throw `${message?.join(',')}`;
|
|
324
|
+
}
|
|
325
|
+
throw message;
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
return result.data;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
export const usePatientVisit = (patientUuid: string) => {
|
|
332
|
+
console.log('patientUuid');
|
|
333
|
+
console.log(patientUuid);
|
|
334
|
+
console.log('patientUuid');
|
|
335
|
+
const sessionLocation = useSession();
|
|
336
|
+
|
|
337
|
+
const url = patientUuid
|
|
338
|
+
? `${restBaseUrl}/visit?patient=${patientUuid}&${sessionLocation?.sessionLocation?.uuid}&includeInactive=false&fromStartDate=${dayjs().startOf('day').toISOString()}&v=full&limit=1`
|
|
339
|
+
: null;
|
|
340
|
+
|
|
341
|
+
const { data, error, isLoading } = useSWR<{
|
|
342
|
+
data: {
|
|
343
|
+
results: Array<Visit>;
|
|
344
|
+
};
|
|
345
|
+
}>(url, openmrsFetch);
|
|
346
|
+
|
|
347
|
+
return {
|
|
348
|
+
data: data?.data?.results,
|
|
349
|
+
error,
|
|
350
|
+
isLoading,
|
|
351
|
+
};
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
export type PreauthAttachmentMeta = {
|
|
355
|
+
document_title: string;
|
|
356
|
+
document_type: string;
|
|
357
|
+
file_field_name: string;
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
/** HIE multipart file field for attachment at zero-based index. */
|
|
361
|
+
export const preauthAttachmentFieldName = (index: number): string => `attachments_${index}_file_blob`;
|
|
362
|
+
|
|
363
|
+
/** Parse index from attachments_N_file_blob; returns null if invalid. */
|
|
364
|
+
export const parsePreauthAttachmentIndex = (fieldName: string): number | null => {
|
|
365
|
+
const match = /^attachments_(\d+)_file_blob$/.exec(fieldName?.trim() ?? '');
|
|
366
|
+
if (!match) return null;
|
|
367
|
+
return Number(match[1]);
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
/**
|
|
371
|
+
* Normalize attachment metadata + files to contiguous indexes 0..n-1.
|
|
372
|
+
* Ensures attachments[i].file_field_name === attachments_i_file_blob and a matching file exists.
|
|
373
|
+
*/
|
|
374
|
+
export const normalizePreauthAttachments = (
|
|
375
|
+
attachments: PreauthAttachmentMeta[] = [],
|
|
376
|
+
files: Record<string, File | Blob> = {},
|
|
377
|
+
): { attachments: PreauthAttachmentMeta[]; files: Record<string, File | Blob> } => {
|
|
378
|
+
const withFiles = attachments
|
|
379
|
+
.map((meta, index) => {
|
|
380
|
+
const declared = meta.file_field_name || preauthAttachmentFieldName(index);
|
|
381
|
+
const file = files[declared] ?? files[preauthAttachmentFieldName(index)];
|
|
382
|
+
if (!file) return null;
|
|
383
|
+
return { meta, file, preferredIndex: parsePreauthAttachmentIndex(declared) ?? index };
|
|
384
|
+
})
|
|
385
|
+
.filter(Boolean) as Array<{ meta: PreauthAttachmentMeta; file: File | Blob; preferredIndex: number }>;
|
|
386
|
+
|
|
387
|
+
// Stable order: by declared index, then original order
|
|
388
|
+
withFiles.sort((a, b) => a.preferredIndex - b.preferredIndex);
|
|
389
|
+
|
|
390
|
+
const normalizedMeta: PreauthAttachmentMeta[] = [];
|
|
391
|
+
const normalizedFiles: Record<string, File | Blob> = {};
|
|
392
|
+
|
|
393
|
+
withFiles.forEach(({ meta, file }, index) => {
|
|
394
|
+
const field = preauthAttachmentFieldName(index);
|
|
395
|
+
normalizedMeta.push({
|
|
396
|
+
document_title: meta.document_title,
|
|
397
|
+
document_type: meta.document_type,
|
|
398
|
+
file_field_name: field,
|
|
399
|
+
});
|
|
400
|
+
normalizedFiles[field] = file;
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
return { attachments: normalizedMeta, files: normalizedFiles };
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
export type PreauthFormPayload = {
|
|
407
|
+
service_start: string;
|
|
408
|
+
service_end: string;
|
|
409
|
+
items: Array<{ unit_price: string; name?: string; quantity?: string }>;
|
|
410
|
+
diagnoses: Array<{ consent_token: string; icd_code: string }>;
|
|
411
|
+
doctors: Array<{
|
|
412
|
+
identification_number: string;
|
|
413
|
+
identification_type: string;
|
|
414
|
+
regulation_body: string;
|
|
415
|
+
intervention_code: string;
|
|
416
|
+
is_primary: boolean;
|
|
417
|
+
}>;
|
|
418
|
+
attachments: PreauthAttachmentMeta[];
|
|
419
|
+
provider_notification_email: string;
|
|
420
|
+
locationUuid: string;
|
|
421
|
+
/** Binary files keyed by file_field_name (e.g. attachments_0_file_blob) */
|
|
422
|
+
files?: Record<string, File | Blob>;
|
|
423
|
+
// Specialty (Postman)
|
|
424
|
+
clinical_indications?: string;
|
|
425
|
+
carcinoma_staging?: string;
|
|
426
|
+
comorbidity?: string;
|
|
427
|
+
metastases?: string[] | string;
|
|
428
|
+
treatment_setting?: string[] | string;
|
|
429
|
+
number_of_sessions_required?: string | number;
|
|
430
|
+
cost_per_session?: string | number;
|
|
431
|
+
is_co_insured?: string | boolean;
|
|
432
|
+
necessity_of_service?: string;
|
|
433
|
+
lens_prescription?: string;
|
|
434
|
+
lens_amount?: string | number;
|
|
435
|
+
eye_examination_amount?: string | number;
|
|
436
|
+
frame_amount?: string | number;
|
|
437
|
+
new_or_replacement?: string;
|
|
438
|
+
frequency_of_sessions?: string;
|
|
439
|
+
start_date?: string;
|
|
440
|
+
progress_report?: string;
|
|
441
|
+
expected_service_start_date?: string;
|
|
442
|
+
is_condition_related_to_employment?: string | boolean;
|
|
443
|
+
is_condition_related_to_auto_or_other_accident?: string | boolean;
|
|
444
|
+
co_insurance_details?: string;
|
|
445
|
+
chief_complaint?: string;
|
|
446
|
+
vital_signs?: string;
|
|
447
|
+
history_of_present_illness?: string;
|
|
448
|
+
physical_examination?: string;
|
|
449
|
+
investigation_report_details?: string;
|
|
450
|
+
type_of_anaesthesia?: string;
|
|
451
|
+
surgery_date?: string;
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
/** Build multipart for POST {hieBaseUrl}/pre-auth/normal.
|
|
455
|
+
* Matches HIE curl POST /api/v1/preauths (snake_case fields + attachments_N_file_blob).
|
|
456
|
+
* Attachment indexes are normalized to 0..n-1 before send.
|
|
457
|
+
*/
|
|
458
|
+
export const generatePreauthFormData = (
|
|
459
|
+
payload: PreauthFormPayload,
|
|
460
|
+
intervention: Pick<
|
|
461
|
+
Intervention,
|
|
462
|
+
| 'code'
|
|
463
|
+
| 'requiresRadiologyPreauth'
|
|
464
|
+
| 'requiresOncologyPreauth'
|
|
465
|
+
| 'requiresOpticalPreauth'
|
|
466
|
+
| 'requiresRenalPreauth'
|
|
467
|
+
| 'requiresSurgicalPreauth'
|
|
468
|
+
>,
|
|
469
|
+
consentToken: string,
|
|
470
|
+
) => {
|
|
471
|
+
const formData = new FormData();
|
|
472
|
+
const { attachments, files } = normalizePreauthAttachments(payload.attachments, payload.files ?? {});
|
|
473
|
+
|
|
474
|
+
formData.append('consent_token', consentToken);
|
|
475
|
+
formData.append('intervention_code', intervention.code);
|
|
476
|
+
formData.append('service_start', payload.service_start);
|
|
477
|
+
formData.append('service_end', payload.service_end);
|
|
478
|
+
formData.append('items', JSON.stringify(payload.items));
|
|
479
|
+
formData.append('diagnoses', JSON.stringify(payload.diagnoses));
|
|
480
|
+
formData.append('doctors', JSON.stringify(payload.doctors));
|
|
481
|
+
formData.append('attachments', JSON.stringify(attachments));
|
|
482
|
+
formData.append('provider_notification_email', payload.provider_notification_email);
|
|
483
|
+
formData.append('locationUuid', payload.locationUuid);
|
|
484
|
+
|
|
485
|
+
// Append in index order: attachments_0_file_blob, attachments_1_file_blob, …
|
|
486
|
+
attachments.forEach((meta) => {
|
|
487
|
+
const file = files[meta.file_field_name];
|
|
488
|
+
if (file) {
|
|
489
|
+
formData.append(meta.file_field_name, file, (file as File).name ?? meta.file_field_name);
|
|
490
|
+
}
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
if (intervention.requiresRadiologyPreauth && payload.clinical_indications) {
|
|
494
|
+
formData.append('clinical_indications', payload.clinical_indications);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/** HIE expects JSON lists for metastases / treatment_setting (e.g. `["LUNG"]`). */
|
|
498
|
+
const asJsonListField = (value: string | string[] | undefined | null): string | null => {
|
|
499
|
+
if (value == null) return null;
|
|
500
|
+
if (Array.isArray(value)) return JSON.stringify(value);
|
|
501
|
+
const trimmed = String(value).trim();
|
|
502
|
+
if (!trimmed) return null;
|
|
503
|
+
if (trimmed.startsWith('[')) return trimmed;
|
|
504
|
+
return JSON.stringify([trimmed]);
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
if (intervention.requiresOncologyPreauth) {
|
|
508
|
+
if (payload.carcinoma_staging) formData.append('carcinoma_staging', payload.carcinoma_staging);
|
|
509
|
+
if (payload.comorbidity) formData.append('comorbidity', payload.comorbidity);
|
|
510
|
+
const metastasesJson = asJsonListField(payload.metastases);
|
|
511
|
+
if (metastasesJson) formData.append('metastases', metastasesJson);
|
|
512
|
+
const treatmentSettingJson = asJsonListField(payload.treatment_setting);
|
|
513
|
+
if (treatmentSettingJson) formData.append('treatment_setting', treatmentSettingJson);
|
|
514
|
+
if (payload.number_of_sessions_required != null) {
|
|
515
|
+
formData.append('number_of_sessions_required', String(payload.number_of_sessions_required));
|
|
516
|
+
}
|
|
517
|
+
if (payload.cost_per_session != null) {
|
|
518
|
+
formData.append('cost_per_session', String(payload.cost_per_session));
|
|
519
|
+
}
|
|
520
|
+
if (payload.is_co_insured != null) {
|
|
521
|
+
formData.append('is_co_insured', String(payload.is_co_insured));
|
|
522
|
+
}
|
|
523
|
+
if (payload.start_date) formData.append('start_date', payload.start_date);
|
|
524
|
+
if (payload.progress_report) formData.append('progress_report', payload.progress_report);
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
if (intervention.requiresOpticalPreauth) {
|
|
528
|
+
if (payload.necessity_of_service) formData.append('necessity_of_service', payload.necessity_of_service);
|
|
529
|
+
if (payload.lens_prescription) formData.append('lens_prescription', payload.lens_prescription);
|
|
530
|
+
if (payload.lens_amount != null) formData.append('lens_amount', String(payload.lens_amount));
|
|
531
|
+
if (payload.eye_examination_amount != null) {
|
|
532
|
+
formData.append('eye_examination_amount', String(payload.eye_examination_amount));
|
|
533
|
+
}
|
|
534
|
+
if (payload.frame_amount != null) formData.append('frame_amount', String(payload.frame_amount));
|
|
535
|
+
if (payload.new_or_replacement) formData.append('new_or_replacement', payload.new_or_replacement);
|
|
536
|
+
if (payload.clinical_indications) formData.append('clinical_indications', payload.clinical_indications);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
if (intervention.requiresRenalPreauth) {
|
|
540
|
+
if (payload.number_of_sessions_required != null) {
|
|
541
|
+
formData.append('number_of_sessions_required', String(payload.number_of_sessions_required));
|
|
542
|
+
}
|
|
543
|
+
if (payload.cost_per_session != null) {
|
|
544
|
+
formData.append('cost_per_session', String(payload.cost_per_session));
|
|
545
|
+
}
|
|
546
|
+
if (payload.frequency_of_sessions) formData.append('frequency_of_sessions', payload.frequency_of_sessions);
|
|
547
|
+
if (payload.clinical_indications) formData.append('clinical_indications', payload.clinical_indications);
|
|
548
|
+
if (payload.start_date) formData.append('start_date', payload.start_date);
|
|
549
|
+
if (payload.is_co_insured != null) formData.append('is_co_insured', String(payload.is_co_insured));
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
// Surgical clinical fields — send snake_case (HIE / gateway expects these keys)
|
|
553
|
+
const hasSurgicalPayload = Boolean(
|
|
554
|
+
payload.chief_complaint?.trim() ||
|
|
555
|
+
payload.vital_signs?.trim() ||
|
|
556
|
+
payload.history_of_present_illness?.trim() ||
|
|
557
|
+
payload.physical_examination?.trim() ||
|
|
558
|
+
payload.investigation_report_details?.trim() ||
|
|
559
|
+
payload.type_of_anaesthesia?.trim() ||
|
|
560
|
+
payload.surgery_date?.trim(),
|
|
561
|
+
);
|
|
562
|
+
if (intervention.requiresSurgicalPreauth || hasSurgicalPayload) {
|
|
563
|
+
const chiefComplaint = (payload.chief_complaint ?? '').trim();
|
|
564
|
+
const vitalSigns = (payload.vital_signs ?? '').trim();
|
|
565
|
+
const historyOfPresentIllness = (payload.history_of_present_illness ?? '').trim();
|
|
566
|
+
const physicalExamination = (payload.physical_examination ?? '').trim();
|
|
567
|
+
const investigationReportDetails = (payload.investigation_report_details ?? '').trim();
|
|
568
|
+
const typeOfAnaesthesia = (payload.type_of_anaesthesia || 'GENERAL').trim();
|
|
569
|
+
const surgeryDate = (payload.surgery_date ?? '').trim();
|
|
570
|
+
|
|
571
|
+
formData.append('chief_complaint', chiefComplaint);
|
|
572
|
+
formData.append('vital_signs', vitalSigns);
|
|
573
|
+
formData.append('history_of_present_illness', historyOfPresentIllness);
|
|
574
|
+
formData.append('physical_examination', physicalExamination);
|
|
575
|
+
formData.append('investigation_report_details', investigationReportDetails);
|
|
576
|
+
formData.append('type_of_anaesthesia', typeOfAnaesthesia);
|
|
577
|
+
if (surgeryDate) {
|
|
578
|
+
formData.append('surgery_date', surgeryDate);
|
|
579
|
+
}
|
|
580
|
+
if (payload.is_condition_related_to_employment != null) {
|
|
581
|
+
formData.append('is_condition_related_to_employment', String(payload.is_condition_related_to_employment));
|
|
582
|
+
}
|
|
583
|
+
if (payload.is_condition_related_to_auto_or_other_accident != null) {
|
|
584
|
+
formData.append(
|
|
585
|
+
'is_condition_related_to_auto_or_other_accident',
|
|
586
|
+
String(payload.is_condition_related_to_auto_or_other_accident),
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
if (payload.is_co_insured != null) {
|
|
590
|
+
formData.append('is_co_insured', String(payload.is_co_insured));
|
|
591
|
+
}
|
|
592
|
+
if (payload.co_insurance_details) {
|
|
593
|
+
formData.append('co_insurance_details', payload.co_insurance_details);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if (payload.expected_service_start_date) {
|
|
598
|
+
formData.append('expected_service_start_date', payload.expected_service_start_date);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
return formData;
|
|
602
|
+
};
|
|
603
|
+
|
|
604
|
+
export async function createPreauth(
|
|
605
|
+
payload: PreauthFormPayload,
|
|
606
|
+
intervention: Pick<
|
|
607
|
+
Intervention,
|
|
608
|
+
| 'code'
|
|
609
|
+
| 'requiresRadiologyPreauth'
|
|
610
|
+
| 'requiresOncologyPreauth'
|
|
611
|
+
| 'requiresOpticalPreauth'
|
|
612
|
+
| 'requiresRenalPreauth'
|
|
613
|
+
| 'requiresSurgicalPreauth'
|
|
614
|
+
>,
|
|
615
|
+
consentToken: string,
|
|
616
|
+
) {
|
|
617
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
618
|
+
const url = `${hieBaseUrl}/pre-auth/normal`;
|
|
619
|
+
const formData = generatePreauthFormData(payload, intervention, consentToken);
|
|
620
|
+
|
|
621
|
+
const result = await openmrsFetch(url, {
|
|
622
|
+
method: 'POST',
|
|
623
|
+
body: formData,
|
|
624
|
+
}).catch((error) => {
|
|
625
|
+
const message = error?.responseBody?.message ?? error?.message ?? 'Failed to create preauth';
|
|
626
|
+
if (typeof message === 'object') {
|
|
627
|
+
throw `${(message as string[])?.join?.(',') ?? JSON.stringify(message)}`;
|
|
628
|
+
}
|
|
629
|
+
throw message;
|
|
630
|
+
});
|
|
631
|
+
|
|
632
|
+
if (result?.data && typeof result.data === 'object' && 'error' in result.data) {
|
|
633
|
+
throw (result.data as { message?: string }).message ?? 'Failed to create preauth';
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return result?.data;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
export async function getPreauthPreview(consentToken: string, locationUuid: string) {
|
|
640
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
641
|
+
const url = `${hieBaseUrl}/pre-auth/preview?consentToken=${encodeURIComponent(consentToken)}&locationUuid=${encodeURIComponent(locationUuid)}`;
|
|
642
|
+
try {
|
|
643
|
+
const result = await openmrsFetch(url);
|
|
644
|
+
return result?.data ?? null;
|
|
645
|
+
} catch (error: any) {
|
|
646
|
+
const status = error?.response?.status ?? error?.status;
|
|
647
|
+
// No preauth raised yet
|
|
648
|
+
if (status === 404) {
|
|
649
|
+
return null;
|
|
650
|
+
}
|
|
651
|
+
const message = error?.responseBody?.message ?? error?.message ?? 'Failed to get preauth preview';
|
|
652
|
+
if (typeof message === 'object') {
|
|
653
|
+
throw `${(message as string[])?.join?.(',') ?? JSON.stringify(message)}`;
|
|
654
|
+
}
|
|
655
|
+
throw message;
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/** Unwrap HIE preview: bare object, array, or paginated `{ results: [...] }`. */
|
|
660
|
+
export function unwrapPreauthPreviewItem(preview: unknown): Record<string, unknown> | null {
|
|
661
|
+
const items = unwrapPreauthPreviewItems(preview);
|
|
662
|
+
return items[0] ?? null;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/** All preauth rows from a preview response (paginated or single). */
|
|
666
|
+
export function unwrapPreauthPreviewItems(preview: unknown): Record<string, unknown>[] {
|
|
667
|
+
if (!preview) {
|
|
668
|
+
return [];
|
|
669
|
+
}
|
|
670
|
+
if (Array.isArray(preview)) {
|
|
671
|
+
return preview.filter((x): x is Record<string, unknown> => !!x && typeof x === 'object');
|
|
672
|
+
}
|
|
673
|
+
if (typeof preview !== 'object') {
|
|
674
|
+
return [];
|
|
675
|
+
}
|
|
676
|
+
const p = preview as Record<string, unknown>;
|
|
677
|
+
if (Array.isArray(p.results)) {
|
|
678
|
+
return p.results.filter((x): x is Record<string, unknown> => !!x && typeof x === 'object');
|
|
679
|
+
}
|
|
680
|
+
return [p];
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
const AWAITING_DOCTOR_STATUSES = new Set([
|
|
684
|
+
'PENDING_DOCTOR_APPROVAL',
|
|
685
|
+
'DOCTOR_REQUEST_SENT',
|
|
686
|
+
'DOCTOR_REQUEST_FAILED',
|
|
687
|
+
]);
|
|
688
|
+
|
|
689
|
+
export function isAwaitingDoctorApproval(
|
|
690
|
+
statusOrItem: string | Record<string, unknown> | null | undefined,
|
|
691
|
+
): boolean {
|
|
692
|
+
if (!statusOrItem) return false;
|
|
693
|
+
if (typeof statusOrItem === 'string') {
|
|
694
|
+
return AWAITING_DOCTOR_STATUSES.has(statusOrItem.toUpperCase());
|
|
695
|
+
}
|
|
696
|
+
const status = String(statusOrItem.status ?? statusOrItem.preauth_status ?? '').toUpperCase();
|
|
697
|
+
if (AWAITING_DOCTOR_STATUSES.has(status)) return true;
|
|
698
|
+
const needs =
|
|
699
|
+
statusOrItem.needsDoctorApproval === true ||
|
|
700
|
+
statusOrItem.needs_doctor_approval === true;
|
|
701
|
+
const approved =
|
|
702
|
+
statusOrItem.doctorApproved === true || statusOrItem.doctor_approved === true;
|
|
703
|
+
return needs && !approved && status !== 'FINALISED' && status !== 'FINALIZED';
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
export type PreauthPreviewRow = {
|
|
707
|
+
id: string;
|
|
708
|
+
consentToken: string;
|
|
709
|
+
status: string;
|
|
710
|
+
preauthType: string;
|
|
711
|
+
interventionCode: string;
|
|
712
|
+
interventionName: string;
|
|
713
|
+
memberName: string;
|
|
714
|
+
memberIdentifier: string;
|
|
715
|
+
preauthToken: string;
|
|
716
|
+
doctorName: string;
|
|
717
|
+
practitionerRegistrationNumber: string;
|
|
718
|
+
needsDoctorApproval: boolean;
|
|
719
|
+
doctorApproved: boolean;
|
|
720
|
+
serviceStart: string;
|
|
721
|
+
/** Payer / provider notes (e.g. clarification after automatic checks). */
|
|
722
|
+
notes: string;
|
|
723
|
+
raw: Record<string, unknown>;
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
/** True when payer asked for clarification / response on an already-raised preauth. */
|
|
727
|
+
export function isPreauthNeedsClarification(status: string): boolean {
|
|
728
|
+
const s = (status || '').toUpperCase();
|
|
729
|
+
return (
|
|
730
|
+
s === 'CLARIFICATION_AFTER_AUTOMATIC_CHECKS' ||
|
|
731
|
+
s === 'PENDING_CLARIFICATION' ||
|
|
732
|
+
s.includes('CLARIFICATION')
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
/** Collect note text from preview row `preauthNotes` / item `responseNote`. */
|
|
737
|
+
export function extractPreauthNotesFromItem(item: Record<string, unknown> | null | undefined): string {
|
|
738
|
+
if (!item) return '';
|
|
739
|
+
const notes = item.preauthNotes ?? item.preauth_notes;
|
|
740
|
+
if (Array.isArray(notes)) {
|
|
741
|
+
const texts = notes
|
|
742
|
+
.map((n) => {
|
|
743
|
+
if (!n || typeof n !== 'object') return '';
|
|
744
|
+
return String((n as Record<string, unknown>).note ?? '').trim();
|
|
745
|
+
})
|
|
746
|
+
.filter(Boolean);
|
|
747
|
+
if (texts.length) return texts.join('\n');
|
|
748
|
+
}
|
|
749
|
+
const items = item.preauthItems ?? item.preauth_items;
|
|
750
|
+
if (Array.isArray(items)) {
|
|
751
|
+
const texts = items
|
|
752
|
+
.map((n) => {
|
|
753
|
+
if (!n || typeof n !== 'object') return '';
|
|
754
|
+
const row = n as Record<string, unknown>;
|
|
755
|
+
return String(row.responseNote ?? row.response_note ?? '').trim();
|
|
756
|
+
})
|
|
757
|
+
.filter(Boolean);
|
|
758
|
+
if (texts.length) return texts.join('\n');
|
|
759
|
+
}
|
|
760
|
+
return '';
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
function firstDoctorProfile(item: Record<string, unknown>): Record<string, unknown> | null {
|
|
764
|
+
const doctors = item.preauthDoctors ?? item.preauth_doctors;
|
|
765
|
+
if (!Array.isArray(doctors) || doctors.length === 0) return null;
|
|
766
|
+
const first = doctors[0] as Record<string, unknown>;
|
|
767
|
+
const profile = (first.doctorProfile ?? first.doctor_profile ?? first) as Record<string, unknown>;
|
|
768
|
+
return profile && typeof profile === 'object' ? profile : null;
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
export function normalizePreauthPreviewItem(
|
|
772
|
+
item: Record<string, unknown>,
|
|
773
|
+
consentToken: string,
|
|
774
|
+
): PreauthPreviewRow {
|
|
775
|
+
const interventionData = (item.interventionData ?? item.intervention_data ?? {}) as Record<
|
|
776
|
+
string,
|
|
777
|
+
unknown
|
|
778
|
+
>;
|
|
779
|
+
const profile = firstDoctorProfile(item);
|
|
780
|
+
const interventionCode = String(
|
|
781
|
+
item.interventionCode ??
|
|
782
|
+
item.intervention_code ??
|
|
783
|
+
interventionData.code ??
|
|
784
|
+
'',
|
|
785
|
+
).trim();
|
|
786
|
+
const interventionName = String(
|
|
787
|
+
interventionData.name ?? item.interventionName ?? interventionCode,
|
|
788
|
+
).trim();
|
|
789
|
+
const status = String(item.status ?? item.preauth_status ?? '').toUpperCase();
|
|
790
|
+
const preauthType = String(
|
|
791
|
+
item.preauthType ??
|
|
792
|
+
item.preauth_type ??
|
|
793
|
+
(item.isOncology || item.is_oncology
|
|
794
|
+
? 'ONCOLOGY'
|
|
795
|
+
: item.isSurgical || item.is_surgical
|
|
796
|
+
? 'SURGICAL'
|
|
797
|
+
: item.isRenal || item.is_renal
|
|
798
|
+
? 'RENAL'
|
|
799
|
+
: item.isRadiology || item.is_radiology
|
|
800
|
+
? 'RADIOLOGY'
|
|
801
|
+
: item.isOptical || item.is_optical
|
|
802
|
+
? 'OPTICAL'
|
|
803
|
+
: 'NORMAL'),
|
|
804
|
+
).toUpperCase();
|
|
805
|
+
const id = String(item.guid ?? item.id ?? `${consentToken}-${interventionCode}-${status}`);
|
|
806
|
+
const practitionerRegistrationNumber = String(
|
|
807
|
+
profile?.practitionerRegistrationNumber ??
|
|
808
|
+
profile?.practitioner_registration_number ??
|
|
809
|
+
profile?.nationalIdentifier ??
|
|
810
|
+
'',
|
|
811
|
+
).trim();
|
|
812
|
+
|
|
813
|
+
return {
|
|
814
|
+
id,
|
|
815
|
+
consentToken,
|
|
816
|
+
status,
|
|
817
|
+
preauthType,
|
|
818
|
+
interventionCode,
|
|
819
|
+
interventionName,
|
|
820
|
+
memberName: String(item.memberName ?? item.member_name ?? '').trim(),
|
|
821
|
+
memberIdentifier: String(item.memberIdentifier ?? item.member_identifier ?? '').trim(),
|
|
822
|
+
preauthToken: String(item.token ?? item.preauth_code ?? item.preauthCode ?? '').trim(),
|
|
823
|
+
doctorName: String(profile?.name ?? '').trim(),
|
|
824
|
+
practitionerRegistrationNumber,
|
|
825
|
+
needsDoctorApproval:
|
|
826
|
+
item.needsDoctorApproval === true || item.needs_doctor_approval === true,
|
|
827
|
+
doctorApproved: item.doctorApproved === true || item.doctor_approved === true,
|
|
828
|
+
serviceStart: String(item.serviceStart ?? item.service_start ?? '').trim(),
|
|
829
|
+
notes: extractPreauthNotesFromItem(item),
|
|
830
|
+
raw: item,
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
export async function resendPreauthDoctorConsent(params: {
|
|
835
|
+
practitionerRegistrationNumber: string;
|
|
836
|
+
consentToken: string;
|
|
837
|
+
interventionCode: string;
|
|
838
|
+
locationUuid: string;
|
|
839
|
+
}) {
|
|
840
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
841
|
+
const url = `${hieBaseUrl}/pre-auth/doctor-consent`;
|
|
842
|
+
const body = {
|
|
843
|
+
practitioner_registration_number: params.practitionerRegistrationNumber,
|
|
844
|
+
request_type: 'PREAUTH_DOCTOR_APPROVAL_REQUEST' as const,
|
|
845
|
+
consent_token: params.consentToken,
|
|
846
|
+
intervention_code: params.interventionCode,
|
|
847
|
+
locationUuid: params.locationUuid,
|
|
848
|
+
};
|
|
849
|
+
try {
|
|
850
|
+
const result = await openmrsFetch(url, {
|
|
851
|
+
method: 'POST',
|
|
852
|
+
headers: { 'Content-Type': 'application/json' },
|
|
853
|
+
body: JSON.stringify(body),
|
|
854
|
+
});
|
|
855
|
+
return result?.data;
|
|
856
|
+
} catch (error: any) {
|
|
857
|
+
const message =
|
|
858
|
+
error?.responseBody?.message ?? error?.message ?? 'Failed to resend doctor consent';
|
|
859
|
+
if (typeof message === 'object') {
|
|
860
|
+
throw `${(message as string[])?.join?.(',') ?? JSON.stringify(message)}`;
|
|
861
|
+
}
|
|
862
|
+
throw message;
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
/**
|
|
867
|
+
* Load all preauth preview rows for a set of claim-visit consent tokens.
|
|
868
|
+
* Tokens without a preauth (404 / empty) are skipped.
|
|
869
|
+
*/
|
|
870
|
+
export async function fetchPreauthPreviewRowsForTokens(
|
|
871
|
+
consentTokens: string[],
|
|
872
|
+
locationUuid: string,
|
|
873
|
+
): Promise<PreauthPreviewRow[]> {
|
|
874
|
+
const unique = [...new Set(consentTokens.map((t) => t.trim()).filter(Boolean))];
|
|
875
|
+
const rows: PreauthPreviewRow[] = [];
|
|
876
|
+
|
|
877
|
+
const CONCURRENCY = 4;
|
|
878
|
+
for (let i = 0; i < unique.length; i += CONCURRENCY) {
|
|
879
|
+
const chunk = unique.slice(i, i + CONCURRENCY);
|
|
880
|
+
const settled = await Promise.all(
|
|
881
|
+
chunk.map(async (token) => {
|
|
882
|
+
try {
|
|
883
|
+
const preview = await getPreauthPreview(token, locationUuid);
|
|
884
|
+
return unwrapPreauthPreviewItems(preview).map((item) =>
|
|
885
|
+
normalizePreauthPreviewItem(item, token),
|
|
886
|
+
);
|
|
887
|
+
} catch {
|
|
888
|
+
return [] as PreauthPreviewRow[];
|
|
889
|
+
}
|
|
890
|
+
}),
|
|
891
|
+
);
|
|
892
|
+
for (const batch of settled) {
|
|
893
|
+
rows.push(...batch);
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
return rows;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
const PREAUTH_TERMINAL_FAILURE = new Set(['REJECTED', 'CANCELLED', 'CANCELED', 'FAILED', 'DECLINED']);
|
|
901
|
+
|
|
902
|
+
const PREAUTH_SUBMITTED = new Set([
|
|
903
|
+
'ACTIVE',
|
|
904
|
+
'PENDING_DOCTOR_APPROVAL',
|
|
905
|
+
'FINALISED',
|
|
906
|
+
'FINALIZED',
|
|
907
|
+
]);
|
|
908
|
+
|
|
909
|
+
function interventionCodeFromPreviewItem(item: Record<string, unknown>): string {
|
|
910
|
+
const interventionData = (item.interventionData ?? item.intervention_data ?? {}) as Record<
|
|
911
|
+
string,
|
|
912
|
+
unknown
|
|
913
|
+
>;
|
|
914
|
+
return String(
|
|
915
|
+
item.interventionCode ?? item.intervention_code ?? interventionData.code ?? '',
|
|
916
|
+
).trim();
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
function statusFromPreviewItem(item: Record<string, unknown>): string {
|
|
920
|
+
const auth = item.authorizationDetails as Record<string, unknown> | undefined;
|
|
921
|
+
// Prefer the row's own status — overallPreauthFinalised is visit-wide and misleading
|
|
922
|
+
// when matching a single intervention.
|
|
923
|
+
const status = String(item.status ?? item.preauth_status ?? '').toUpperCase();
|
|
924
|
+
const doctorReview = String(item.doctorReviewStatus ?? item.doctor_review_status ?? '').toUpperCase();
|
|
925
|
+
|
|
926
|
+
if (
|
|
927
|
+
doctorReview &&
|
|
928
|
+
PREAUTH_TERMINAL_FAILURE.has(doctorReview) &&
|
|
929
|
+
status !== 'FINALISED' &&
|
|
930
|
+
status !== 'FINALIZED'
|
|
931
|
+
) {
|
|
932
|
+
return doctorReview;
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
if (!status && (auth?.overallPreauthFinalised === true || auth?.overall_preauth_finalised === true)) {
|
|
936
|
+
return 'FINALISED';
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
return status;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
/** Find the preview row for a specific intervention code (paginated `results[]`). */
|
|
943
|
+
export function findPreauthPreviewForIntervention(
|
|
944
|
+
preview: unknown,
|
|
945
|
+
interventionCode: string,
|
|
946
|
+
): Record<string, unknown> | null {
|
|
947
|
+
const code = (interventionCode ?? '').trim();
|
|
948
|
+
if (!code) return null;
|
|
949
|
+
const items = unwrapPreauthPreviewItems(preview);
|
|
950
|
+
const direct =
|
|
951
|
+
items.find((item) => interventionCodeFromPreviewItem(item) === code) ?? null;
|
|
952
|
+
if (direct) return direct;
|
|
953
|
+
|
|
954
|
+
// Some payloads only stamp the code on nested preauthItems[].
|
|
955
|
+
return (
|
|
956
|
+
items.find((item) => {
|
|
957
|
+
const nested = item.preauthItems ?? item.preauth_items;
|
|
958
|
+
if (!Array.isArray(nested)) return false;
|
|
959
|
+
return nested.some((n) => {
|
|
960
|
+
if (!n || typeof n !== 'object') return false;
|
|
961
|
+
const row = n as Record<string, unknown>;
|
|
962
|
+
return String(row.interventionCode ?? row.intervention_code ?? '').trim() === code;
|
|
963
|
+
});
|
|
964
|
+
}) ?? null
|
|
965
|
+
);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
export function extractPreauthStatusForIntervention(preview: unknown, interventionCode: string): string {
|
|
969
|
+
const item = findPreauthPreviewForIntervention(preview, interventionCode);
|
|
970
|
+
if (!item) return '';
|
|
971
|
+
return statusFromPreviewItem(item);
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
export function extractPreauthCodeForIntervention(
|
|
975
|
+
preview: unknown,
|
|
976
|
+
interventionCode: string,
|
|
977
|
+
): string | undefined {
|
|
978
|
+
const item = findPreauthPreviewForIntervention(preview, interventionCode);
|
|
979
|
+
if (!item) return undefined;
|
|
980
|
+
return extractPreauthCode(item);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/**
|
|
984
|
+
* True when preview already has a non-failed, non-clarification preauth for this
|
|
985
|
+
* intervention — Raise should be hidden. Terminal failure and clarification allow
|
|
986
|
+
* reopening the form to resubmit.
|
|
987
|
+
*/
|
|
988
|
+
export function interventionHasBlockingPreauth(preview: unknown, interventionCode: string): boolean {
|
|
989
|
+
const item = findPreauthPreviewForIntervention(preview, interventionCode);
|
|
990
|
+
if (!item) return false;
|
|
991
|
+
const status = statusFromPreviewItem(item);
|
|
992
|
+
if (!status) return true; // row exists but status blank — treat as already raised
|
|
993
|
+
return !isPreauthResubmittable(status);
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
/**
|
|
997
|
+
* True when this intervention's preauth failed or needs clarification —
|
|
998
|
+
* UI can offer Resubmit and reopen the preauth form.
|
|
999
|
+
*/
|
|
1000
|
+
export function interventionHasFailedPreauth(preview: unknown, interventionCode: string): boolean {
|
|
1001
|
+
const status = extractPreauthStatusForIntervention(preview, interventionCode);
|
|
1002
|
+
return Boolean(status) && isPreauthResubmittable(status);
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
/** Alias for clarity at call sites that mean "resubmit", not only hard failure. */
|
|
1006
|
+
export function interventionAllowsPreauthResubmit(
|
|
1007
|
+
preview: unknown,
|
|
1008
|
+
interventionCode: string,
|
|
1009
|
+
): boolean {
|
|
1010
|
+
return interventionHasFailedPreauth(preview, interventionCode);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
export function extractPreauthStatus(preview: unknown): string {
|
|
1014
|
+
const item = unwrapPreauthPreviewItem(preview);
|
|
1015
|
+
if (!item) {
|
|
1016
|
+
return '';
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
const auth = item.authorizationDetails as Record<string, unknown> | undefined;
|
|
1020
|
+
if (auth?.overallPreauthFinalised === true || auth?.overall_preauth_finalised === true) {
|
|
1021
|
+
return 'FINALISED';
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
return statusFromPreviewItem(item);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
export function extractPreauthCode(preview: unknown): string | undefined {
|
|
1028
|
+
const item = unwrapPreauthPreviewItem(preview);
|
|
1029
|
+
if (!item) {
|
|
1030
|
+
return undefined;
|
|
1031
|
+
}
|
|
1032
|
+
const auth = item.authorizationDetails as Record<string, unknown> | undefined;
|
|
1033
|
+
const fromAuth =
|
|
1034
|
+
(auth?.authCode as string) ||
|
|
1035
|
+
(auth?.auth_code as string) ||
|
|
1036
|
+
(auth?.token as string) ||
|
|
1037
|
+
undefined;
|
|
1038
|
+
|
|
1039
|
+
return (
|
|
1040
|
+
(item.preauth_code as string) ||
|
|
1041
|
+
(item.preauthCode as string) ||
|
|
1042
|
+
(item.token as string) ||
|
|
1043
|
+
fromAuth ||
|
|
1044
|
+
(item.authCode as string) ||
|
|
1045
|
+
(item.id != null ? String(item.id) : undefined) ||
|
|
1046
|
+
(item.preauth_id != null ? String(item.preauth_id) : undefined)
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
export function isPreauthFinalised(status: string): boolean {
|
|
1051
|
+
const s = (status || '').toUpperCase();
|
|
1052
|
+
return s === 'FINALISED' || s === 'FINALIZED';
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
export function isPreauthTerminalFailure(status: string): boolean {
|
|
1056
|
+
const s = (status || '').toUpperCase();
|
|
1057
|
+
if (PREAUTH_TERMINAL_FAILURE.has(s)) return true;
|
|
1058
|
+
// HIE sometimes returns prefixed / alternate spellings (e.g. PREAUTH_CANCELLED).
|
|
1059
|
+
return s.includes('CANCEL');
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/** Failure, cancellation, or clarification — provider may reopen the preauth form and resubmit. */
|
|
1063
|
+
export function isPreauthResubmittable(status: string): boolean {
|
|
1064
|
+
return isPreauthTerminalFailure(status) || isPreauthNeedsClarification(status);
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
/** Statuses that mean the preauth was accepted by HIE — form can close. */
|
|
1068
|
+
export function isPreauthSubmitted(status: string): boolean {
|
|
1069
|
+
return PREAUTH_SUBMITTED.has((status || '').toUpperCase());
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
export type PreauthCheckKind = 'not_raised' | 'finalised' | 'pending' | 'failed' | 'error';
|
|
1073
|
+
|
|
1074
|
+
export type PreauthCheckResult = {
|
|
1075
|
+
status: string;
|
|
1076
|
+
preauthCode?: string;
|
|
1077
|
+
preview: unknown;
|
|
1078
|
+
kind: PreauthCheckKind;
|
|
1079
|
+
notes?: string;
|
|
1080
|
+
error?: string;
|
|
1081
|
+
};
|
|
1082
|
+
|
|
1083
|
+
/** One-shot preauth status check for lists, gates, and non-React callers. */
|
|
1084
|
+
export async function checkPreauthStatus(
|
|
1085
|
+
consentToken: string | null | undefined,
|
|
1086
|
+
locationUuid: string | null | undefined,
|
|
1087
|
+
interventionCode?: string | null,
|
|
1088
|
+
): Promise<PreauthCheckResult> {
|
|
1089
|
+
if (!consentToken?.trim()) {
|
|
1090
|
+
return {
|
|
1091
|
+
status: '',
|
|
1092
|
+
preview: null,
|
|
1093
|
+
kind: 'error',
|
|
1094
|
+
error: 'Missing consent token',
|
|
1095
|
+
};
|
|
1096
|
+
}
|
|
1097
|
+
if (!locationUuid?.trim()) {
|
|
1098
|
+
return {
|
|
1099
|
+
status: '',
|
|
1100
|
+
preview: null,
|
|
1101
|
+
kind: 'error',
|
|
1102
|
+
error: 'Missing location',
|
|
1103
|
+
};
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
try {
|
|
1107
|
+
const preview = await getPreauthPreview(consentToken.trim(), locationUuid.trim());
|
|
1108
|
+
const code = (interventionCode ?? '').trim();
|
|
1109
|
+
const item = code
|
|
1110
|
+
? findPreauthPreviewForIntervention(preview, code)
|
|
1111
|
+
: unwrapPreauthPreviewItem(preview);
|
|
1112
|
+
// Paginated empty results / null body → not raised
|
|
1113
|
+
if (!preview || !item) {
|
|
1114
|
+
return { status: '', preview, kind: 'not_raised' };
|
|
1115
|
+
}
|
|
1116
|
+
|
|
1117
|
+
const status = code
|
|
1118
|
+
? extractPreauthStatusForIntervention(preview, code)
|
|
1119
|
+
: extractPreauthStatus(preview);
|
|
1120
|
+
const preauthCode = code
|
|
1121
|
+
? extractPreauthCodeForIntervention(preview, code)
|
|
1122
|
+
: extractPreauthCode(preview);
|
|
1123
|
+
const notes = extractPreauthNotesFromItem(item);
|
|
1124
|
+
|
|
1125
|
+
if (!status) {
|
|
1126
|
+
// Row exists for this intervention but status blank — treat as already raised.
|
|
1127
|
+
return { status: '', preview, kind: 'pending', preauthCode, notes };
|
|
1128
|
+
}
|
|
1129
|
+
if (isPreauthFinalised(status)) {
|
|
1130
|
+
return { status: 'FINALISED', preview, kind: 'finalised', preauthCode, notes };
|
|
1131
|
+
}
|
|
1132
|
+
if (isPreauthTerminalFailure(status)) {
|
|
1133
|
+
return { status, preview, kind: 'failed', preauthCode, notes };
|
|
1134
|
+
}
|
|
1135
|
+
// Clarification stays `pending` for status-tag colouring ("Needs clarification"),
|
|
1136
|
+
// but is not a blocking preauth — callers use isPreauthNeedsClarification / resubmit helpers.
|
|
1137
|
+
return { status, preview, kind: 'pending', preauthCode, notes };
|
|
1138
|
+
} catch (e: unknown) {
|
|
1139
|
+
const message = e instanceof Error ? e.message : String(e ?? 'Failed to get preauth preview');
|
|
1140
|
+
return {
|
|
1141
|
+
status: '',
|
|
1142
|
+
preview: null,
|
|
1143
|
+
kind: 'error',
|
|
1144
|
+
error: message,
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
export const preauthPreviewSwrKey = (consentToken: string, locationUuid: string) =>
|
|
1150
|
+
['preauth-preview', consentToken, locationUuid] as const;
|
|
1151
|
+
|
|
1152
|
+
/** SWR hook for reusable preauth status elsewhere in the app. */
|
|
1153
|
+
export function usePreauthPreview(consentToken: string | null | undefined, locationUuid: string | null | undefined) {
|
|
1154
|
+
const key =
|
|
1155
|
+
consentToken?.trim() && locationUuid?.trim()
|
|
1156
|
+
? preauthPreviewSwrKey(consentToken.trim(), locationUuid.trim())
|
|
1157
|
+
: null;
|
|
1158
|
+
|
|
1159
|
+
const { data, error, isLoading, isValidating, mutate } = useSWR(key, ([, token, loc]) =>
|
|
1160
|
+
checkPreauthStatus(token, loc),
|
|
1161
|
+
);
|
|
1162
|
+
|
|
1163
|
+
return {
|
|
1164
|
+
preview: data?.preview ?? null,
|
|
1165
|
+
status: data?.status ?? '',
|
|
1166
|
+
preauthCode: data?.preauthCode,
|
|
1167
|
+
kind: data?.kind,
|
|
1168
|
+
check: data,
|
|
1169
|
+
error: error ?? (data?.kind === 'error' ? data.error : undefined),
|
|
1170
|
+
isLoading,
|
|
1171
|
+
isValidating,
|
|
1172
|
+
mutate,
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
export async function invalidatePreauthPreview(consentToken: string, locationUuid: string) {
|
|
1177
|
+
if (!consentToken?.trim() || !locationUuid?.trim()) return;
|
|
1178
|
+
await globalMutate(preauthPreviewSwrKey(consentToken.trim(), locationUuid.trim()));
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/** Poll GET /pre-auth/preview until FINALISED or a terminal failure. */
|
|
1182
|
+
export async function pollPreauthUntilFinalised(
|
|
1183
|
+
consentToken: string,
|
|
1184
|
+
locationUuid: string,
|
|
1185
|
+
{
|
|
1186
|
+
intervalMs = 3000,
|
|
1187
|
+
maxAttempts = 40,
|
|
1188
|
+
signal,
|
|
1189
|
+
}: { intervalMs?: number; maxAttempts?: number; signal?: AbortSignal } = {},
|
|
1190
|
+
): Promise<{ status: string; preview: unknown; preauthCode?: string }> {
|
|
1191
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1192
|
+
if (signal?.aborted) {
|
|
1193
|
+
throw new Error('Preauth poll cancelled');
|
|
1194
|
+
}
|
|
1195
|
+
const preview = await getPreauthPreview(consentToken, locationUuid);
|
|
1196
|
+
const status = extractPreauthStatus(preview);
|
|
1197
|
+
if (isPreauthFinalised(status)) {
|
|
1198
|
+
return { status: 'FINALISED', preview, preauthCode: extractPreauthCode(preview) };
|
|
1199
|
+
}
|
|
1200
|
+
if (status && isPreauthTerminalFailure(status)) {
|
|
1201
|
+
throw new Error(`Preauth ${status}`);
|
|
1202
|
+
}
|
|
1203
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
1204
|
+
}
|
|
1205
|
+
throw new Error('Timed out waiting for preauth to reach FINALISED');
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* Poll until the matching intervention's preauth is ACTIVE, PENDING_DOCTOR_APPROVAL,
|
|
1210
|
+
* or FINALISED — enough to close the Raise form without waiting on payer finalisation.
|
|
1211
|
+
*/
|
|
1212
|
+
export async function pollPreauthUntilSubmitted(
|
|
1213
|
+
consentToken: string,
|
|
1214
|
+
locationUuid: string,
|
|
1215
|
+
interventionCode: string,
|
|
1216
|
+
{
|
|
1217
|
+
intervalMs = 3000,
|
|
1218
|
+
maxAttempts = 40,
|
|
1219
|
+
signal,
|
|
1220
|
+
}: { intervalMs?: number; maxAttempts?: number; signal?: AbortSignal } = {},
|
|
1221
|
+
): Promise<{ status: string; preview: unknown; preauthCode?: string }> {
|
|
1222
|
+
const code = (interventionCode ?? '').trim();
|
|
1223
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
1224
|
+
if (signal?.aborted) {
|
|
1225
|
+
throw new Error('Preauth poll cancelled');
|
|
1226
|
+
}
|
|
1227
|
+
const preview = await getPreauthPreview(consentToken, locationUuid);
|
|
1228
|
+
const status = code
|
|
1229
|
+
? extractPreauthStatusForIntervention(preview, code)
|
|
1230
|
+
: extractPreauthStatus(preview);
|
|
1231
|
+
if (status && isPreauthSubmitted(status)) {
|
|
1232
|
+
return {
|
|
1233
|
+
status: isPreauthFinalised(status) ? 'FINALISED' : status,
|
|
1234
|
+
preview,
|
|
1235
|
+
preauthCode: code
|
|
1236
|
+
? extractPreauthCodeForIntervention(preview, code)
|
|
1237
|
+
: extractPreauthCode(preview),
|
|
1238
|
+
};
|
|
1239
|
+
}
|
|
1240
|
+
if (status && isPreauthTerminalFailure(status)) {
|
|
1241
|
+
throw new Error(`Preauth ${status}`);
|
|
1242
|
+
}
|
|
1243
|
+
await new Promise((resolve) => setTimeout(resolve, intervalMs));
|
|
1244
|
+
}
|
|
1245
|
+
throw new Error('Timed out waiting for preauth submission confirmation');
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
export const getServiceType = (selectedIntervention: Intervention, visitType?: VisitType): ServiceType => {
|
|
1249
|
+
const paymentMechanism = selectedIntervention.paymentMechanism;
|
|
1250
|
+
const accessPoint = selectedIntervention.accessPoint;
|
|
1251
|
+
|
|
1252
|
+
if (paymentMechanism.trim().toUpperCase() === 'CAPITATION') {
|
|
1253
|
+
return 'CAPITATION';
|
|
1254
|
+
}
|
|
1255
|
+
if (["PER DIEM", "PER_DIEM"].includes(paymentMechanism.trim().toUpperCase())) {
|
|
1256
|
+
return 'INPATIENT';
|
|
1257
|
+
}
|
|
1258
|
+
if (accessPoint.trim().toUpperCase() === 'IP') {
|
|
1259
|
+
return 'INPATIENT';
|
|
1260
|
+
}
|
|
1261
|
+
if (accessPoint.trim().toUpperCase() === 'OP') {
|
|
1262
|
+
return 'OUTPATIENT';
|
|
1263
|
+
}
|
|
1264
|
+
if (accessPoint.trim().toUpperCase() === 'OP AND IP') {
|
|
1265
|
+
return visitType;
|
|
1266
|
+
}
|
|
1267
|
+
return visitType;
|
|
1268
|
+
};
|
|
1269
|
+
|
|
1270
|
+
export const createPreauthRequest = async (preauthRequest: PreauthRequest) => {
|
|
1271
|
+
const hieBaseUrl = await getHieBaseUrl();
|
|
1272
|
+
const postUrl = `${hieBaseUrl}/pre-auth/request`;
|
|
1273
|
+
return openmrsFetch<{}>(postUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: preauthRequest });
|
|
1274
|
+
};
|