@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,1072 @@
|
|
|
1
|
+
import { openmrsFetch, restBaseUrl, type Visit } from '@openmrs/esm-framework';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import { fetchFacilityPreauthBills, fetchPatientFacilityBillDetails } from '../../../billing-claims.resource';
|
|
4
|
+
import { fetchShaInterventionByCode } from '../../../../claims/claims.resource';
|
|
5
|
+
import { type Intervention } from '../../../../claims';
|
|
6
|
+
import { IdentifierTypesUuids } from '../../../../resources/identifier-types';
|
|
7
|
+
import { type PatientFacilityBillDetails } from '../types';
|
|
8
|
+
import { getConsentToken } from '../../../../shared/services/claims.resource';
|
|
9
|
+
|
|
10
|
+
const PREAUTH_CODE_KEY = 'ampath.preauthCode';
|
|
11
|
+
|
|
12
|
+
export const asBool = (v: unknown): boolean => {
|
|
13
|
+
if (typeof v === 'boolean') return v;
|
|
14
|
+
if (typeof v === 'number') return v === 1;
|
|
15
|
+
if (typeof v === 'string') {
|
|
16
|
+
const s = v.trim().toLowerCase();
|
|
17
|
+
return s === 'true' || s === '1' || s === 'yes';
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** Score how well a billable_service name matches an intervention / service hint. */
|
|
23
|
+
function scoreBillableServiceMatch(billableService: string | null | undefined, hint: string | null | undefined): number {
|
|
24
|
+
const a = (billableService ?? '').toLowerCase().trim();
|
|
25
|
+
const b = (hint ?? '').toLowerCase().trim();
|
|
26
|
+
if (!a || !b) return 0;
|
|
27
|
+
if (a === b) return 100;
|
|
28
|
+
if (a.includes(b) || b.includes(a)) return 80;
|
|
29
|
+
const tokensA = a.split(/[^a-z0-9]+/).filter((t) => t.length > 2);
|
|
30
|
+
const tokensB = b.split(/[^a-z0-9]+/).filter((t) => t.length > 2);
|
|
31
|
+
if (!tokensA.length || !tokensB.length) return 0;
|
|
32
|
+
const overlap = tokensA.filter((t) => tokensB.includes(t)).length;
|
|
33
|
+
return overlap * 15;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Pick the bill line for a preauth intervention.
|
|
38
|
+
* Same intervention_code can appear on multiple lines (e.g. HEMOGLOBIN + HEMODIALYSIS) —
|
|
39
|
+
* prefer the line whose billable_service best matches the service hint / intervention name.
|
|
40
|
+
*/
|
|
41
|
+
export function pickBillLineForIntervention(
|
|
42
|
+
bills: PatientFacilityBillDetails[],
|
|
43
|
+
interventionCode: string,
|
|
44
|
+
serviceHint?: string | null,
|
|
45
|
+
): PatientFacilityBillDetails | null {
|
|
46
|
+
const code = (interventionCode ?? '').trim();
|
|
47
|
+
if (!code || !bills?.length) return null;
|
|
48
|
+
|
|
49
|
+
const byCode = bills.filter((b) => (b.intervention_code ?? '').trim() === code);
|
|
50
|
+
if (!byCode.length) return null;
|
|
51
|
+
|
|
52
|
+
let best: PatientFacilityBillDetails = byCode[0];
|
|
53
|
+
let bestRanked = -1;
|
|
54
|
+
for (const line of byCode) {
|
|
55
|
+
const score = scoreBillableServiceMatch(line.billable_service, serviceHint);
|
|
56
|
+
const price = Number(line.item_price ?? 0) || 0;
|
|
57
|
+
// Name match dominates; among ties prefer higher item_price.
|
|
58
|
+
const ranked = score * 1_000_000 + price;
|
|
59
|
+
if (ranked > bestRanked) {
|
|
60
|
+
bestRanked = ranked;
|
|
61
|
+
best = line;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return best;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function unitPriceFromBillLine(line: PatientFacilityBillDetails | null | undefined): string {
|
|
68
|
+
if (!line) return '';
|
|
69
|
+
const price = line.item_price ?? line.item_total_price;
|
|
70
|
+
if (price == null || price === ('' as unknown)) return '';
|
|
71
|
+
const n = Number(price);
|
|
72
|
+
return Number.isFinite(n) ? String(n) : String(price).trim();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** SHA coverage flags for an intervention_code (from interventions coverage API). */
|
|
76
|
+
export type ShaInterventionPreauthFlags = {
|
|
77
|
+
needsPreauth: boolean;
|
|
78
|
+
needsManualPreauthApproval: boolean;
|
|
79
|
+
intervention?: Intervention | null;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Bill lines that need elective preauth (`needsManualPreauthApproval`) and are not yet approved.
|
|
84
|
+
*/
|
|
85
|
+
export const needsElectivePreauth = (item: PatientFacilityBillDetails): boolean => {
|
|
86
|
+
if (!item?.intervention_code) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
if (asBool(item.preauth_approved)) {
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
if (item.elective_preauth != null) {
|
|
93
|
+
return asBool(item.elective_preauth);
|
|
94
|
+
}
|
|
95
|
+
return false;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Bill lines that need normal (non-elective) preauth and are not yet approved.
|
|
100
|
+
* Prefer ETL flags when present; otherwise use SHA intervention coverage for the
|
|
101
|
+
* bill's `intervention_code` (`needsPreauth` && !`needsManualPreauthApproval`).
|
|
102
|
+
* @see https://hie-docs.dha.go.ke/docs/claims/process/preauths/normalPreauths
|
|
103
|
+
*/
|
|
104
|
+
export const needsNormalPreauth = (
|
|
105
|
+
item: PatientFacilityBillDetails,
|
|
106
|
+
sha?: ShaInterventionPreauthFlags | null,
|
|
107
|
+
): boolean => {
|
|
108
|
+
if (!item?.intervention_code) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (asBool(item.preauth_approved)) {
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
// Elective is a separate queue / workspace mode
|
|
115
|
+
if (asBool(item.elective_preauth)) {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
// Prefer explicit ETL flags when the bill payload includes them
|
|
119
|
+
if (item.requires_preauth != null) {
|
|
120
|
+
return asBool(item.requires_preauth) && !asBool(item.elective_preauth);
|
|
121
|
+
}
|
|
122
|
+
if (item.normal_preauth != null) {
|
|
123
|
+
return asBool(item.normal_preauth);
|
|
124
|
+
}
|
|
125
|
+
// Facility bill lines often omit ETL flags — use SHA coverage for intervention_code
|
|
126
|
+
if (sha) {
|
|
127
|
+
return Boolean(sha.needsPreauth) && !Boolean(sha.needsManualPreauthApproval);
|
|
128
|
+
}
|
|
129
|
+
return false;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Resolve normal-preauth need for a bill line via SHA interventions coverage
|
|
134
|
+
* using `cr_no` + `intervention_code` (+ optional `subBenefitCode` from claim visit).
|
|
135
|
+
*/
|
|
136
|
+
export async function resolveNormalPreauthForBillItem(
|
|
137
|
+
item: PatientFacilityBillDetails,
|
|
138
|
+
locationUuid: string,
|
|
139
|
+
subBenefitCode?: string,
|
|
140
|
+
): Promise<ShaInterventionPreauthFlags | null> {
|
|
141
|
+
const code = (item.intervention_code ?? '').trim();
|
|
142
|
+
const patientId = (item.cr_no ?? '').trim();
|
|
143
|
+
if (!code || !patientId || !locationUuid) {
|
|
144
|
+
return null;
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const intervention = await fetchShaInterventionByCode(
|
|
148
|
+
patientId,
|
|
149
|
+
locationUuid,
|
|
150
|
+
code,
|
|
151
|
+
subBenefitCode,
|
|
152
|
+
);
|
|
153
|
+
if (!intervention) {
|
|
154
|
+
return { needsPreauth: false, needsManualPreauthApproval: false, intervention: null };
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
needsPreauth: Boolean(intervention.needsPreauth),
|
|
158
|
+
needsManualPreauthApproval: Boolean(intervention.needsManualPreauthApproval),
|
|
159
|
+
intervention,
|
|
160
|
+
};
|
|
161
|
+
} catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export async function fetchActiveVisitForPatient(patientUuid: string, locationUuid?: string): Promise<Visit | null> {
|
|
167
|
+
if (!patientUuid) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const params = new URLSearchParams({
|
|
171
|
+
patient: patientUuid,
|
|
172
|
+
includeInactive: 'false',
|
|
173
|
+
fromStartDate: dayjs().startOf('day').toISOString(),
|
|
174
|
+
v: 'full',
|
|
175
|
+
limit: '1',
|
|
176
|
+
});
|
|
177
|
+
if (locationUuid) {
|
|
178
|
+
params.set('location', locationUuid);
|
|
179
|
+
}
|
|
180
|
+
const response = await openmrsFetch(`${restBaseUrl}/visit?${params.toString()}`);
|
|
181
|
+
const results = response?.data?.results as Visit[] | undefined;
|
|
182
|
+
return results?.[0] ?? null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export async function fetchNormalPreauthBillItems(
|
|
186
|
+
locationUuid: string,
|
|
187
|
+
billingDate: string,
|
|
188
|
+
): Promise<PatientFacilityBillDetails[]> {
|
|
189
|
+
const results = await fetchFacilityPreauthBills({ locationUuid, billingDate });
|
|
190
|
+
// Dedicated `/facility/pre-auth-bills` already returns preauth candidates; still drop
|
|
191
|
+
// elective / already-approved / lines without an intervention code.
|
|
192
|
+
return (results ?? []).filter((item) => {
|
|
193
|
+
if (!item?.intervention_code) return false;
|
|
194
|
+
if (asBool(item.preauth_approved)) return false;
|
|
195
|
+
if (asBool(item.elective_preauth)) return false;
|
|
196
|
+
if (item.requires_preauth != null || item.normal_preauth != null) {
|
|
197
|
+
return needsNormalPreauth(item);
|
|
198
|
+
}
|
|
199
|
+
return true;
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export async function fetchElectivePreauthBillItems(
|
|
204
|
+
locationUuid: string,
|
|
205
|
+
billingDate: string,
|
|
206
|
+
): Promise<PatientFacilityBillDetails[]> {
|
|
207
|
+
const results = await fetchFacilityPreauthBills({ locationUuid, billingDate });
|
|
208
|
+
return (results ?? []).filter((item) => needsElectivePreauth(item));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export async function fetchPreauthBillItems(
|
|
212
|
+
locationUuid: string,
|
|
213
|
+
billingDate: string,
|
|
214
|
+
): Promise<PatientFacilityBillDetails[]> {
|
|
215
|
+
const results = await fetchFacilityPreauthBills({ locationUuid, billingDate });
|
|
216
|
+
return (results ?? []).filter((item) => {
|
|
217
|
+
if (!item?.intervention_code) return false;
|
|
218
|
+
if (asBool(item.preauth_approved)) return false;
|
|
219
|
+
if (asBool(item.elective_preauth)) return true;
|
|
220
|
+
if (item.requires_preauth != null || item.normal_preauth != null) {
|
|
221
|
+
return needsNormalPreauth(item);
|
|
222
|
+
}
|
|
223
|
+
return true;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export function resolveConsentTokenForVisit(visit: Visit | null | undefined): string {
|
|
228
|
+
if (!visit) return '';
|
|
229
|
+
return getConsentToken(visit);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function storePreauthCode(consentToken: string, interventionCode: string, preauthCode: string) {
|
|
233
|
+
try {
|
|
234
|
+
const raw = sessionStorage.getItem(PREAUTH_CODE_KEY);
|
|
235
|
+
const map = raw ? (JSON.parse(raw) as Record<string, string>) : {};
|
|
236
|
+
map[`${consentToken}::${interventionCode}`] = preauthCode;
|
|
237
|
+
sessionStorage.setItem(PREAUTH_CODE_KEY, JSON.stringify(map));
|
|
238
|
+
} catch {
|
|
239
|
+
// ignore
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function getStoredPreauthCode(consentToken: string, interventionCode: string): string | undefined {
|
|
244
|
+
try {
|
|
245
|
+
const raw = sessionStorage.getItem(PREAUTH_CODE_KEY);
|
|
246
|
+
if (!raw) return undefined;
|
|
247
|
+
const map = JSON.parse(raw) as Record<string, string>;
|
|
248
|
+
return map[`${consentToken}::${interventionCode}`];
|
|
249
|
+
} catch {
|
|
250
|
+
return undefined;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
export function parseDocTypes(csv?: string | null): string[] {
|
|
255
|
+
if (!csv) return [];
|
|
256
|
+
return csv
|
|
257
|
+
.split(',')
|
|
258
|
+
.map((s) => s.trim())
|
|
259
|
+
.filter(Boolean);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export function interventionFlagsFromBillItem(item: PatientFacilityBillDetails) {
|
|
263
|
+
return {
|
|
264
|
+
code: item.intervention_code,
|
|
265
|
+
...readSpecialtyFlags(item),
|
|
266
|
+
requiredPreauthDocumentTypes: parseDocTypes(item.required_preauth_document_types),
|
|
267
|
+
applicableDocumentTypes: parseDocTypes(item.applicable_document_types),
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Specialty flags from visit/SHA/bill payloads (snake_case or camelCase). */
|
|
272
|
+
export function readSpecialtyFlags(source: unknown): {
|
|
273
|
+
requiresSurgicalPreauth: boolean;
|
|
274
|
+
requiresRenalPreauth: boolean;
|
|
275
|
+
requiresOncologyPreauth: boolean;
|
|
276
|
+
requiresRadiologyPreauth: boolean;
|
|
277
|
+
requiresOpticalPreauth: boolean;
|
|
278
|
+
} {
|
|
279
|
+
const s = (source ?? {}) as Record<string, unknown>;
|
|
280
|
+
return {
|
|
281
|
+
requiresSurgicalPreauth: asBool(s.requiresSurgicalPreauth ?? s.requires_surgical_preauth),
|
|
282
|
+
requiresRenalPreauth: asBool(s.requiresRenalPreauth ?? s.requires_renal_preauth),
|
|
283
|
+
requiresOncologyPreauth: asBool(s.requiresOncologyPreauth ?? s.requires_oncology_preauth),
|
|
284
|
+
requiresRadiologyPreauth: asBool(s.requiresRadiologyPreauth ?? s.requires_radiology_preauth),
|
|
285
|
+
requiresOpticalPreauth: asBool(s.requiresOpticalPreauth ?? s.requires_optical_preauth),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export function mergeSpecialtyFlags(
|
|
290
|
+
...sources: Array<ReturnType<typeof readSpecialtyFlags> | null | undefined>
|
|
291
|
+
): ReturnType<typeof readSpecialtyFlags> {
|
|
292
|
+
return sources.reduce(
|
|
293
|
+
(acc, src) => ({
|
|
294
|
+
requiresSurgicalPreauth: acc.requiresSurgicalPreauth || !!src?.requiresSurgicalPreauth,
|
|
295
|
+
requiresRenalPreauth: acc.requiresRenalPreauth || !!src?.requiresRenalPreauth,
|
|
296
|
+
requiresOncologyPreauth: acc.requiresOncologyPreauth || !!src?.requiresOncologyPreauth,
|
|
297
|
+
requiresRadiologyPreauth: acc.requiresRadiologyPreauth || !!src?.requiresRadiologyPreauth,
|
|
298
|
+
requiresOpticalPreauth: acc.requiresOpticalPreauth || !!src?.requiresOpticalPreauth,
|
|
299
|
+
}),
|
|
300
|
+
{
|
|
301
|
+
requiresSurgicalPreauth: false,
|
|
302
|
+
requiresRenalPreauth: false,
|
|
303
|
+
requiresOncologyPreauth: false,
|
|
304
|
+
requiresRadiologyPreauth: false,
|
|
305
|
+
requiresOpticalPreauth: false,
|
|
306
|
+
},
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export function preauthFormLabel(flags: {
|
|
311
|
+
requiresSurgicalPreauth?: boolean;
|
|
312
|
+
requiresRenalPreauth?: boolean;
|
|
313
|
+
requiresOncologyPreauth?: boolean;
|
|
314
|
+
requiresRadiologyPreauth?: boolean;
|
|
315
|
+
requiresOpticalPreauth?: boolean;
|
|
316
|
+
}): string {
|
|
317
|
+
if (flags.requiresSurgicalPreauth) return 'Surgical';
|
|
318
|
+
if (flags.requiresRenalPreauth) return 'Renal';
|
|
319
|
+
if (flags.requiresOncologyPreauth) return 'Oncology';
|
|
320
|
+
if (flags.requiresRadiologyPreauth) return 'Imaging';
|
|
321
|
+
if (flags.requiresOpticalPreauth) return 'Optical';
|
|
322
|
+
return 'Normal';
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
export type PreauthInterventionProps = {
|
|
326
|
+
code: string;
|
|
327
|
+
name?: string;
|
|
328
|
+
requiresSurgicalPreauth?: boolean;
|
|
329
|
+
requiresRenalPreauth?: boolean;
|
|
330
|
+
requiresOncologyPreauth?: boolean;
|
|
331
|
+
requiresRadiologyPreauth?: boolean;
|
|
332
|
+
requiresOpticalPreauth?: boolean;
|
|
333
|
+
requiredPreauthDocumentTypes?: string[];
|
|
334
|
+
applicableDocumentTypes?: string[];
|
|
335
|
+
};
|
|
336
|
+
|
|
337
|
+
export const GENERATABLE_DOC_TYPES = new Set(['DISCHARGE_SUMMARY', 'INVOICE', 'FINAL_BILL']);
|
|
338
|
+
|
|
339
|
+
export type OpenMrsProviderHit = {
|
|
340
|
+
uuid: string;
|
|
341
|
+
display: string;
|
|
342
|
+
identifier?: string;
|
|
343
|
+
/** From provider attribute type PROVIDER_NATIONAL_ID_UUID (National ID card) */
|
|
344
|
+
nationalId?: string;
|
|
345
|
+
person?: { display?: string; uuid?: string };
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
function extractProviderNationalId(
|
|
349
|
+
attributes?: Array<{ value?: string; voided?: boolean; attributeType?: { uuid?: string } }>,
|
|
350
|
+
): string | undefined {
|
|
351
|
+
const hit = (attributes ?? []).find(
|
|
352
|
+
(a) => !a.voided && a.attributeType?.uuid === IdentifierTypesUuids.PROVIDER_NATIONAL_ID_UUID && a.value,
|
|
353
|
+
);
|
|
354
|
+
return hit?.value ? String(hit.value).trim() : undefined;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export async function searchOpenMrsProviders(q: string): Promise<OpenMrsProviderHit[]> {
|
|
358
|
+
if (!q || q.trim().length < 2) {
|
|
359
|
+
return [];
|
|
360
|
+
}
|
|
361
|
+
const url = `${restBaseUrl}/provider?q=${encodeURIComponent(q.trim())}&v=custom:(uuid,display,identifier,person:(uuid,display),attributes:(uuid,value,voided,attributeType:(uuid)))`;
|
|
362
|
+
const response = await openmrsFetch(url);
|
|
363
|
+
const results = (response?.data?.results as Array<OpenMrsProviderHit & { attributes?: any[] }>) ?? [];
|
|
364
|
+
return results.map((p) => ({
|
|
365
|
+
uuid: p.uuid,
|
|
366
|
+
display: p.display,
|
|
367
|
+
identifier: p.identifier,
|
|
368
|
+
person: p.person,
|
|
369
|
+
nationalId: extractProviderNationalId(p.attributes),
|
|
370
|
+
}));
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/** ICD-11 concept source used by AMRS / ETL patient diagnosis (claims-and-billing). */
|
|
374
|
+
export const ICD11_CONCEPT_SOURCE_UUID = '43aaca5f-d623-43fd-993b-673b5d927cdd';
|
|
375
|
+
|
|
376
|
+
export type DiagnosisConceptHit = {
|
|
377
|
+
uuid: string;
|
|
378
|
+
display: string;
|
|
379
|
+
icd11Code: string;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
type ConceptMappingLike = {
|
|
383
|
+
display?: string;
|
|
384
|
+
conceptReferenceTerm?: {
|
|
385
|
+
code?: string;
|
|
386
|
+
name?: string;
|
|
387
|
+
conceptSource?: { uuid?: string; name?: string; hl7Code?: string };
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
function extractIcd11CodeFromConcept(concept: {
|
|
392
|
+
mappings?: ConceptMappingLike[];
|
|
393
|
+
}): string {
|
|
394
|
+
for (const m of concept.mappings ?? []) {
|
|
395
|
+
const term = m.conceptReferenceTerm;
|
|
396
|
+
if (!term) continue;
|
|
397
|
+
const source = term.conceptSource ?? {};
|
|
398
|
+
const sourceUuid = String(source.uuid ?? '');
|
|
399
|
+
const sourceName = String(source.name ?? '').toUpperCase();
|
|
400
|
+
const hl7 = String(source.hl7Code ?? '').toUpperCase();
|
|
401
|
+
if (
|
|
402
|
+
sourceUuid === ICD11_CONCEPT_SOURCE_UUID ||
|
|
403
|
+
sourceName.includes('ICD-11') ||
|
|
404
|
+
sourceName.includes('ICD11') ||
|
|
405
|
+
hl7 === 'ICD11' ||
|
|
406
|
+
hl7.includes('ICD-11')
|
|
407
|
+
) {
|
|
408
|
+
const code = String(term.code ?? '').trim();
|
|
409
|
+
if (code) return code;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
for (const m of concept.mappings ?? []) {
|
|
413
|
+
const display = String(m.display ?? '');
|
|
414
|
+
if (/ICD-?11/i.test(display)) {
|
|
415
|
+
const code = display.split(':').pop()?.trim();
|
|
416
|
+
if (code) return code;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return '';
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* Search the OpenMRS concept dictionary for ICD-11–mapped diagnosis concepts.
|
|
424
|
+
* Used when the clerk types in Raise Preauth (visit diagnoses still prefill the list).
|
|
425
|
+
*/
|
|
426
|
+
export async function searchDiagnosisConcepts(q: string): Promise<DiagnosisConceptHit[]> {
|
|
427
|
+
const term = (q ?? '').trim();
|
|
428
|
+
if (term.length < 2) {
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
const params = new URLSearchParams({
|
|
432
|
+
q: term,
|
|
433
|
+
limit: '25',
|
|
434
|
+
v: 'custom:(uuid,display,mappings:(display,conceptReferenceTerm:(uuid,code,name,conceptSource:(uuid,name,hl7Code))))',
|
|
435
|
+
});
|
|
436
|
+
const response = await openmrsFetch(`${restBaseUrl}/concept?${params.toString()}`);
|
|
437
|
+
const results = (response?.data?.results as Array<{
|
|
438
|
+
uuid: string;
|
|
439
|
+
display: string;
|
|
440
|
+
mappings?: ConceptMappingLike[];
|
|
441
|
+
}>) ?? [];
|
|
442
|
+
|
|
443
|
+
const hits: DiagnosisConceptHit[] = [];
|
|
444
|
+
const seen = new Set<string>();
|
|
445
|
+
for (const c of results) {
|
|
446
|
+
const icd11Code = extractIcd11CodeFromConcept(c);
|
|
447
|
+
if (!icd11Code) continue;
|
|
448
|
+
const key = `${icd11Code}|${c.uuid}`;
|
|
449
|
+
if (seen.has(key)) continue;
|
|
450
|
+
seen.add(key);
|
|
451
|
+
hits.push({
|
|
452
|
+
uuid: c.uuid,
|
|
453
|
+
display: c.display || icd11Code,
|
|
454
|
+
icd11Code,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
return hits;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export type HwrSearchResult = {
|
|
461
|
+
membership?: {
|
|
462
|
+
id?: string;
|
|
463
|
+
full_name?: string;
|
|
464
|
+
registration_id?: string;
|
|
465
|
+
licensing_body?: string;
|
|
466
|
+
specialty?: string;
|
|
467
|
+
status?: string;
|
|
468
|
+
};
|
|
469
|
+
contacts?: { email?: string; phone?: string };
|
|
470
|
+
identifiers?: {
|
|
471
|
+
identification_type?: string;
|
|
472
|
+
identification_number?: string;
|
|
473
|
+
client_registry_id?: string;
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
|
|
477
|
+
/** GET {hieBaseUrl}/practitioner/search */
|
|
478
|
+
export async function searchHealthWorkerRegistry(params: {
|
|
479
|
+
identifierType: string;
|
|
480
|
+
identifierValue: string;
|
|
481
|
+
locationUuid: string;
|
|
482
|
+
}): Promise<HwrSearchResult[]> {
|
|
483
|
+
const { getHieBaseUrl } = await import('../../../../claims/utils');
|
|
484
|
+
const { hieBaseUrl } = await getHieBaseUrl();
|
|
485
|
+
const qs = new URLSearchParams({
|
|
486
|
+
identifierType: params.identifierType,
|
|
487
|
+
identifierValue: params.identifierValue,
|
|
488
|
+
locationUuid: params.locationUuid,
|
|
489
|
+
});
|
|
490
|
+
const response = await openmrsFetch(`${hieBaseUrl}/practitioner/search?${qs.toString()}`);
|
|
491
|
+
const data = response?.data;
|
|
492
|
+
if (Array.isArray(data)) {
|
|
493
|
+
// Backend may return HealthWokerApiResponse[] with { message } wrappers
|
|
494
|
+
return data.map((row: any) => row?.message ?? row).filter(Boolean);
|
|
495
|
+
}
|
|
496
|
+
if (data?.message) {
|
|
497
|
+
return [data.message];
|
|
498
|
+
}
|
|
499
|
+
return data ? [data] : [];
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
export function billingDateToVisitDate(billDate?: string): string {
|
|
503
|
+
if (!billDate) {
|
|
504
|
+
return dayjs().format('YYYY-MM-DD');
|
|
505
|
+
}
|
|
506
|
+
// "2026-07-23 12:16" or ISO
|
|
507
|
+
const d = dayjs(billDate);
|
|
508
|
+
return d.isValid() ? d.format('YYYY-MM-DD') : dayjs().format('YYYY-MM-DD');
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Load patient facility bill lines and resolve unit_price for the intervention.
|
|
513
|
+
* Handles multiple lines sharing one intervention_code by matching billable_service.
|
|
514
|
+
*/
|
|
515
|
+
export async function resolveUnitPriceFromPatientBills(params: {
|
|
516
|
+
patientUuid: string;
|
|
517
|
+
locationUuid: string;
|
|
518
|
+
billingDate?: string;
|
|
519
|
+
interventionCode: string;
|
|
520
|
+
serviceHint?: string | null;
|
|
521
|
+
}): Promise<{ unitPrice: string; billLine: PatientFacilityBillDetails | null }> {
|
|
522
|
+
const patientUuid = (params.patientUuid ?? '').trim();
|
|
523
|
+
const locationUuid = (params.locationUuid ?? '').trim();
|
|
524
|
+
const interventionCode = (params.interventionCode ?? '').trim();
|
|
525
|
+
if (!patientUuid || !locationUuid || !interventionCode) {
|
|
526
|
+
return { unitPrice: '', billLine: null };
|
|
527
|
+
}
|
|
528
|
+
try {
|
|
529
|
+
const billingDate = billingDateToVisitDate(params.billingDate);
|
|
530
|
+
const bills = await fetchPatientFacilityBillDetails({
|
|
531
|
+
patientUuid,
|
|
532
|
+
locationUuid,
|
|
533
|
+
billingDate,
|
|
534
|
+
});
|
|
535
|
+
const line = pickBillLineForIntervention(bills ?? [], interventionCode, params.serviceHint);
|
|
536
|
+
return { unitPrice: unitPriceFromBillLine(line), billLine: line };
|
|
537
|
+
} catch {
|
|
538
|
+
return { unitPrice: '', billLine: null };
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/** Build service_start/service_end ISO. `timeOrEndOfDay` may be "HH:mm" / "HH:mm:ss", or true for end-of-day. */
|
|
543
|
+
export function dateToServiceIso(date: Date | undefined, timeOrEndOfDay: string | boolean = false): string {
|
|
544
|
+
if (!date || Number.isNaN(date.getTime())) {
|
|
545
|
+
return dayjs().format('YYYY-MM-DDTHH:mm:ssZ');
|
|
546
|
+
}
|
|
547
|
+
if (typeof timeOrEndOfDay === 'string') {
|
|
548
|
+
const parts = timeOrEndOfDay.split(':').map((p) => Number(p));
|
|
549
|
+
const [h = 0, m = 0, s = 0] = parts;
|
|
550
|
+
return dayjs(date).hour(h).minute(m).second(s).format('YYYY-MM-DDTHH:mm:ssZ');
|
|
551
|
+
}
|
|
552
|
+
const d = timeOrEndOfDay
|
|
553
|
+
? dayjs(date).hour(23).minute(59).second(0)
|
|
554
|
+
: dayjs(date).hour(8).minute(0).second(0);
|
|
555
|
+
return d.format('YYYY-MM-DDTHH:mm:ssZ');
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
/** POC Pre-authorization Form encounter type. */
|
|
559
|
+
export const PREAUTH_ENCOUNTER_TYPE_UUID = '18b10189-a89f-430d-83e9-14663fef258c';
|
|
560
|
+
|
|
561
|
+
/** Clinical notes / indications concept — same UUID as admissions clinical notes. */
|
|
562
|
+
export const CLINICAL_INDICATIONS_CONCEPT_UUID = '5e4dc798-2cce-4a1a-97e9-bcf22d64b07c';
|
|
563
|
+
|
|
564
|
+
export const PREAUTH_FORM_CONCEPTS = {
|
|
565
|
+
clinicalIndication: CLINICAL_INDICATIONS_CONCEPT_UUID,
|
|
566
|
+
startDate: 'bb85532e-8f7e-476f-81d7-5580e0385852',
|
|
567
|
+
sessionNumber: '86f4e2e2-c2e8-4d0b-9ed7-34900d55ae09',
|
|
568
|
+
frequencyOfSessions: 'a40396d3-3f9b-49b6-902a-a804f3d0e2a0',
|
|
569
|
+
complaintGroup: '9014962e-3efe-46b0-a393-c8c8bddadaa7',
|
|
570
|
+
complaint: 'a8a6ddb6-1350-11df-a1f1-0026b9348838',
|
|
571
|
+
otherComplaint: 'a8a06fc6-1350-11df-a1f1-0026b9348838',
|
|
572
|
+
hpi: '9e903280-385f-473d-9dfb-01bdb6b661a5',
|
|
573
|
+
generalExam: 'a8a0cc32-1350-11df-a1f1-0026b9348838',
|
|
574
|
+
investigation: '7b64016c-ae2d-4ec1-bdc1-e920b0e94b9d',
|
|
575
|
+
anaesthesia: '2ea4944e-51e4-52c7-a209-8dcc2e889054',
|
|
576
|
+
employmentRelated: '7dcf0456-a9ec-42d3-aa75-d406d3e5abb1',
|
|
577
|
+
accidentRelated: '855b3a01-53c9-4129-923d-79863d318580',
|
|
578
|
+
coInsured: '415dbca0-2d9b-4d6a-98b7-b855a023cbbb',
|
|
579
|
+
coInsuredDetails: '226c4f3a-3db3-4244-adc3-bc224b90d8fe',
|
|
580
|
+
yes: 'a899b35c-1350-11df-a1f1-0026b9348838',
|
|
581
|
+
no: 'a899b42e-1350-11df-a1f1-0026b9348838',
|
|
582
|
+
} as const;
|
|
583
|
+
|
|
584
|
+
const FREQUENCY_CONCEPT_TO_HIE: Record<string, string> = {
|
|
585
|
+
// Confirmed from live PREAUTHORIZATION encounter (ONCE A WEEK)
|
|
586
|
+
'5dcfe297-2ef7-4f1c-97e3-a519c18fcc84': 'ONCE_A_WEEK',
|
|
587
|
+
'690b2ab2-4cbc-4df4-be19-64b8a93981ab': 'ONCE_EVERY_2_WEEKS',
|
|
588
|
+
'72ec1de0-4bf0-4c40-9329-b8f574a64132': 'ONCE_EVERY_3_WEEKS',
|
|
589
|
+
'a899d7f6-1350-11df-a1f1-0026b9348838': 'ONCE_A_MONTH',
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
function mapFrequencyFromObs(obs: Record<string, unknown> | undefined): string {
|
|
593
|
+
if (!obs) return '';
|
|
594
|
+
const uuid = codedUuid(obs.value);
|
|
595
|
+
if (uuid && FREQUENCY_CONCEPT_TO_HIE[uuid]) {
|
|
596
|
+
return FREQUENCY_CONCEPT_TO_HIE[uuid];
|
|
597
|
+
}
|
|
598
|
+
// Fallback when form schema used placeholder UUIDs but display names are correct
|
|
599
|
+
const display = codedDisplay(obs.value).toUpperCase().replace(/\s+/g, ' ');
|
|
600
|
+
if (!display) return '';
|
|
601
|
+
if (display.includes('TWICE') && display.includes('WEEK')) return 'TWICE_A_WEEK';
|
|
602
|
+
if (
|
|
603
|
+
(display.includes('ONCE') || display.includes('ONE TIME') || display.includes('EVERY')) &&
|
|
604
|
+
display.includes('WEEK') &&
|
|
605
|
+
!display.includes('2') &&
|
|
606
|
+
!display.includes('3')
|
|
607
|
+
) {
|
|
608
|
+
return 'ONCE_A_WEEK';
|
|
609
|
+
}
|
|
610
|
+
if (display.includes('2 WEEK') || display.includes('EVERY 2')) return 'ONCE_EVERY_2_WEEKS';
|
|
611
|
+
if (display.includes('3 WEEK') || display.includes('EVERY 3')) return 'ONCE_EVERY_3_WEEKS';
|
|
612
|
+
if (display.includes('MONTH')) return 'ONCE_A_MONTH';
|
|
613
|
+
return '';
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
const ANAESTHESIA_CONCEPT_TO_HIE: Record<string, string> = {
|
|
617
|
+
'7a69a31a-d88f-4ebd-a00b-cb5b4581de00': 'GENERAL',
|
|
618
|
+
'074225d4-b1be-56e9-93f6-255ebf106df3': 'LOCAL',
|
|
619
|
+
'3fa5c3a8-41e5-493a-9ab7-7177fc6f8c82': 'SEDATION',
|
|
620
|
+
'f45ac884-e73e-4b02-9d8b-49c4e3ce5a15': 'SPINAL',
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
/** Complaint coded answers from POC Pre-authorization Form → display labels. */
|
|
624
|
+
const COMPLAINT_CONCEPT_TO_LABEL: Record<string, string> = {
|
|
625
|
+
'a8932f00-1350-11df-a1f1-0026b9348838': 'Abdominal pain',
|
|
626
|
+
'a0bda074-8e57-4ba7-ab9c-c008776f8d48': 'Abnormal uterine bleeding',
|
|
627
|
+
'a89cec02-1350-11df-a1f1-0026b9348838': 'Anxiety',
|
|
628
|
+
'a8953d90-1350-11df-a1f1-0026b9348838': 'Back pain',
|
|
629
|
+
'a8981696-1350-11df-a1f1-0026b9348838': 'Bloody urine',
|
|
630
|
+
'bb1637fd-dd30-4938-a7a7-30dcef155f38': 'Blood in stool',
|
|
631
|
+
'c7356bfe-e9a8-422b-9a6a-6e42490d308e': 'Breast pain',
|
|
632
|
+
'a892e4b4-1350-11df-a1f1-0026b9348838': 'Chest pain',
|
|
633
|
+
'a898314e-1350-11df-a1f1-0026b9348838': 'Cold and chills',
|
|
634
|
+
'a8ad3b02-1350-11df-a1f1-0026b9348838': 'Confusion',
|
|
635
|
+
'a890d73c-1350-11df-a1f1-0026b9348838': 'Cough',
|
|
636
|
+
'b9655bbd-a94f-41a6-a5c6-4ea9ed83e840': 'Convulsions',
|
|
637
|
+
'894e909e-881c-4ac3-b669-4c77003831ad': 'Coma',
|
|
638
|
+
'a890d660-1350-11df-a1f1-0026b9348838': 'Coryza',
|
|
639
|
+
'96dafdc7-720e-4eac-85d3-ae2a0f5c1d94': 'Crying infant',
|
|
640
|
+
'a58cfd5c-a237-46fd-b0fc-bb7f2192bb69': 'Delirium',
|
|
641
|
+
'a8935fde-1350-11df-a1f1-0026b9348838': 'Depression',
|
|
642
|
+
'a890861a-1350-11df-a1f1-0026b9348838': 'Diarrhoea',
|
|
643
|
+
'a8a454d8-1350-11df-a1f1-0026b9348838': 'Difficult in breathing',
|
|
644
|
+
'a8983cc0-1350-11df-a1f1-0026b9348838': 'Difficulty in swallowing',
|
|
645
|
+
'abb19bab-e77d-47db-b9b6-18386868e1b3': 'Discharge from penis',
|
|
646
|
+
'e5c11905-baf7-4747-a01d-0525153e143a': 'Dizziness',
|
|
647
|
+
'eb12bfd6-dd52-4c41-a35e-a8048c975e7f': 'Ear Pain',
|
|
648
|
+
'9a9cb2d4-696c-4f2b-9a7b-206333597e3c': 'Epigastric pain',
|
|
649
|
+
'05354fc6-fd53-4c40-9379-ba2b4457635e': 'Eye pain',
|
|
650
|
+
'd301ff85-d21c-4a61-a195-ce7948db423c': 'Excessive sweating',
|
|
651
|
+
'4a3fa87f-0f09-4b70-bfaf-ed9cba1f9aa7': 'Facial pain',
|
|
652
|
+
'4b92fa43-a876-4fee-886b-ce4fc2e18512': 'Fatigue/weakness',
|
|
653
|
+
'cebb22fc-5ef8-409e-b606-51fdb7039593': 'Flank pain',
|
|
654
|
+
'a8ad0038-1350-11df-a1f1-0026b9348838': 'Fever',
|
|
655
|
+
'8065a17b-fbe4-4558-9ddd-0af641866c21': 'General body malaise',
|
|
656
|
+
'4eef684c-feff-48bb-9e8e-fe5742bee979': 'Genital ulcer',
|
|
657
|
+
'a8966d1e-1350-11df-a1f1-0026b9348838': 'Headache',
|
|
658
|
+
'13a3c07c-e870-4cc9-b7d3-d2e5b5e60a3e': 'Hearing loss',
|
|
659
|
+
'a89d1222-1350-11df-a1f1-0026b9348838': 'Hypotension',
|
|
660
|
+
'a8983ae0-1350-11df-a1f1-0026b9348838': 'Itchiness/Pruritus',
|
|
661
|
+
'a890ba5e-1350-11df-a1f1-0026b9348838': 'Joint pain',
|
|
662
|
+
'be9da369-ba93-4a0c-afdd-616ed4b434e8': 'Leg pain',
|
|
663
|
+
'a8ad042a-1350-11df-a1f1-0026b9348838': 'Lethargy',
|
|
664
|
+
'a8982eba-1350-11df-a1f1-0026b9348838': 'Loss of appetite',
|
|
665
|
+
'a893378e-1350-11df-a1f1-0026b9348838': 'Lymphadenopathy',
|
|
666
|
+
'5d91ee3c-9ace-462f-97c1-bd0c8fcf8a5e': 'Memory loss',
|
|
667
|
+
'6fac98a0-6d8a-4441-aeed-c447a3a12494': 'Mouth ulceration',
|
|
668
|
+
'02dc5deb-44d1-43db-b65e-9eb0d6cedaaf': 'Mouth pain',
|
|
669
|
+
'1fbf7fd4-ea3e-4ab1-acd9-bf215651e066': 'Muscle cramps',
|
|
670
|
+
'a8ad5330-1350-11df-a1f1-0026b9348838': 'Muscle pain',
|
|
671
|
+
'a890e2f4-1350-11df-a1f1-0026b9348838': 'Mylagia',
|
|
672
|
+
'a8ad21e4-1350-11df-a1f1-0026b9348838': 'Nausea',
|
|
673
|
+
'a8a6b476-1350-11df-a1f1-0026b9348838': 'Neck stiffness',
|
|
674
|
+
'bb7fc04f-13d8-4630-b9d8-e364b34b7f2f': 'Neck pain',
|
|
675
|
+
'a8ad4ed0-1350-11df-a1f1-0026b9348838': 'Night sweats',
|
|
676
|
+
'4ef1a2d0-132d-4a02-b0e0-00890b916343': 'Numbness',
|
|
677
|
+
'a8a498ee-1350-11df-a1f1-0026b9348838': 'Unexplained bleeding',
|
|
678
|
+
'd4abb20f-fde4-453b-b7e8-ac35debe83c2': 'Pelvic pain',
|
|
679
|
+
'a8ad09ca-1350-11df-a1f1-0026b9348838': 'Poor vision',
|
|
680
|
+
'a895776a-1350-11df-a1f1-0026b9348838': 'Rash',
|
|
681
|
+
'0df011cb-3ff1-465e-ae84-718da974aedd': 'Red Eye/ conjuctivitis',
|
|
682
|
+
'a8ad4476-1350-11df-a1f1-0026b9348838': 'Refusal to feed',
|
|
683
|
+
'a8983bda-1350-11df-a1f1-0026b9348838': 'Running/Blocked nose',
|
|
684
|
+
'773bfb25-09c8-4920-89f5-5bdafe5b5b62': 'Scrotal pain',
|
|
685
|
+
'a8935f0c-1350-11df-a1f1-0026b9348838': 'Seizure',
|
|
686
|
+
'4fd5f4cf-67cd-444d-8f18-a01afb4d9af0': 'Shoulder pain',
|
|
687
|
+
'8ccbbecf-58cd-43c2-ae9a-a36a4e578b25': 'Shock',
|
|
688
|
+
'a8932d66-1350-11df-a1f1-0026b9348838': 'Sore throat',
|
|
689
|
+
'34c96419-d4a9-4377-8c80-3a31d0f07d13': 'Sleep disturbance',
|
|
690
|
+
'e01c7959-551c-4c40-bcbf-52ef3087cbff': 'Swollen legs',
|
|
691
|
+
'ae5f2fc7-3f76-4fc3-96fa-72b354323821': 'Tremors',
|
|
692
|
+
'0ca4d1dc-34df-4ec0-bf2f-0280005ce6c9': 'Urinary symptoms',
|
|
693
|
+
'9abe711c-5e02-4aca-8d70-8b2148a17256': 'Watery diarrhoea',
|
|
694
|
+
'c982b4fe-8403-4c67-9650-91da17aecf5e': 'Weakness of limbs',
|
|
695
|
+
'a89807f0-1350-11df-a1f1-0026b9348838': 'Weight loss',
|
|
696
|
+
'a89d145c-1350-11df-a1f1-0026b9348838': 'Vaginal bleeding',
|
|
697
|
+
'a8ad2eb4-1350-11df-a1f1-0026b9348838': 'Vaginal discharge',
|
|
698
|
+
'a8ad239c-1350-11df-a1f1-0026b9348838': 'Vomiting',
|
|
699
|
+
'6d140ca3-118d-48ca-9d91-7b5612987413': 'Vertigo',
|
|
700
|
+
'a8aaf3e2-1350-11df-a1f1-0026b9348838': 'Other',
|
|
701
|
+
};
|
|
702
|
+
|
|
703
|
+
export type PreauthFormFieldKey =
|
|
704
|
+
| 'clinicalIndications'
|
|
705
|
+
| 'startDate'
|
|
706
|
+
| 'sessionsRequired'
|
|
707
|
+
| 'frequency'
|
|
708
|
+
| 'chiefComplaint'
|
|
709
|
+
| 'hpi'
|
|
710
|
+
| 'physicalExam'
|
|
711
|
+
| 'investigations'
|
|
712
|
+
| 'anaesthesia'
|
|
713
|
+
| 'surgeryDate'
|
|
714
|
+
| 'relatedToEmployment'
|
|
715
|
+
| 'relatedToAccident'
|
|
716
|
+
| 'isCoInsured'
|
|
717
|
+
| 'coInsuranceDetails';
|
|
718
|
+
|
|
719
|
+
export type PreauthFormValues = {
|
|
720
|
+
clinicalIndications: string;
|
|
721
|
+
startDate: string;
|
|
722
|
+
sessionsRequired: string;
|
|
723
|
+
frequency: string;
|
|
724
|
+
chiefComplaint: string;
|
|
725
|
+
hpi: string;
|
|
726
|
+
physicalExam: string;
|
|
727
|
+
investigations: string;
|
|
728
|
+
anaesthesia: string;
|
|
729
|
+
surgeryDate: string;
|
|
730
|
+
relatedToEmployment: boolean | null;
|
|
731
|
+
relatedToAccident: boolean | null;
|
|
732
|
+
isCoInsured: boolean | null;
|
|
733
|
+
coInsuranceDetails: string;
|
|
734
|
+
/** Keys that had a real value from the form / obs. */
|
|
735
|
+
found: Set<PreauthFormFieldKey>;
|
|
736
|
+
source: 'encounter' | 'obs' | 'none';
|
|
737
|
+
};
|
|
738
|
+
|
|
739
|
+
function emptyPreauthFormValues(source: PreauthFormValues['source'] = 'none'): PreauthFormValues {
|
|
740
|
+
return {
|
|
741
|
+
clinicalIndications: '',
|
|
742
|
+
startDate: '',
|
|
743
|
+
sessionsRequired: '',
|
|
744
|
+
frequency: '',
|
|
745
|
+
chiefComplaint: '',
|
|
746
|
+
hpi: '',
|
|
747
|
+
physicalExam: '',
|
|
748
|
+
investigations: '',
|
|
749
|
+
anaesthesia: '',
|
|
750
|
+
surgeryDate: '',
|
|
751
|
+
relatedToEmployment: null,
|
|
752
|
+
relatedToAccident: null,
|
|
753
|
+
isCoInsured: null,
|
|
754
|
+
coInsuranceDetails: '',
|
|
755
|
+
found: new Set(),
|
|
756
|
+
source,
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
function conceptUuidOf(obs: Record<string, unknown>): string {
|
|
761
|
+
const c = obs.concept;
|
|
762
|
+
if (typeof c === 'string') return c;
|
|
763
|
+
if (c && typeof c === 'object' && 'uuid' in c) return String((c as { uuid: string }).uuid ?? '');
|
|
764
|
+
return '';
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function codedUuid(value: unknown): string {
|
|
768
|
+
if (!value) return '';
|
|
769
|
+
if (typeof value === 'string') return value;
|
|
770
|
+
if (typeof value === 'object' && value !== null && 'uuid' in value) {
|
|
771
|
+
return String((value as { uuid: string }).uuid ?? '');
|
|
772
|
+
}
|
|
773
|
+
return '';
|
|
774
|
+
}
|
|
775
|
+
|
|
776
|
+
function codedDisplay(value: unknown): string {
|
|
777
|
+
if (!value || typeof value !== 'object') return '';
|
|
778
|
+
const v = value as { display?: string; name?: { display?: string } };
|
|
779
|
+
return String(v.display ?? v.name?.display ?? '').trim();
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
function obsTextValue(obs: Record<string, unknown> | null | undefined): string {
|
|
783
|
+
if (!obs) return '';
|
|
784
|
+
if (typeof obs.valueText === 'string' && obs.valueText.trim()) {
|
|
785
|
+
return obs.valueText.trim();
|
|
786
|
+
}
|
|
787
|
+
const value = obs.value;
|
|
788
|
+
if (typeof value === 'string' && value.trim()) {
|
|
789
|
+
return value.trim();
|
|
790
|
+
}
|
|
791
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
792
|
+
return String(value);
|
|
793
|
+
}
|
|
794
|
+
return '';
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
function obsNumericValue(obs: Record<string, unknown> | null | undefined): string {
|
|
798
|
+
if (!obs) return '';
|
|
799
|
+
const value = obs.value;
|
|
800
|
+
if (typeof value === 'number' && Number.isFinite(value)) return String(value);
|
|
801
|
+
if (typeof value === 'string' && value.trim() && !Number.isNaN(Number(value))) return value.trim();
|
|
802
|
+
return obsTextValue(obs);
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
function obsDateIso(obs: Record<string, unknown> | null | undefined): string {
|
|
806
|
+
if (!obs) return '';
|
|
807
|
+
const raw =
|
|
808
|
+
(typeof obs.valueDate === 'string' && obs.valueDate) ||
|
|
809
|
+
(typeof obs.valueDatetime === 'string' && obs.valueDatetime) ||
|
|
810
|
+
(typeof obs.value === 'string' && obs.value) ||
|
|
811
|
+
'';
|
|
812
|
+
const d = dayjs(raw);
|
|
813
|
+
return d.isValid() ? d.format('YYYY-MM-DDTHH:mm:ssZ') : '';
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
function obsYesNo(obs: Record<string, unknown> | null | undefined): boolean | null {
|
|
817
|
+
if (!obs) return null;
|
|
818
|
+
const uuid = codedUuid(obs.value);
|
|
819
|
+
if (uuid === PREAUTH_FORM_CONCEPTS.yes) return true;
|
|
820
|
+
if (uuid === PREAUTH_FORM_CONCEPTS.no) return false;
|
|
821
|
+
return null;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
function flattenObs(obsList: unknown[]): Record<string, unknown>[] {
|
|
825
|
+
const out: Record<string, unknown>[] = [];
|
|
826
|
+
for (const item of obsList ?? []) {
|
|
827
|
+
if (!item || typeof item !== 'object') continue;
|
|
828
|
+
const obs = item as Record<string, unknown>;
|
|
829
|
+
out.push(obs);
|
|
830
|
+
const groupMembers = obs.groupMembers ?? obs.group_members;
|
|
831
|
+
if (Array.isArray(groupMembers)) {
|
|
832
|
+
out.push(...flattenObs(groupMembers));
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
return out;
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function latestObsByConcept(obsList: Record<string, unknown>[]): Map<string, Record<string, unknown>> {
|
|
839
|
+
const map = new Map<string, Record<string, unknown>>();
|
|
840
|
+
const sorted = [...obsList].sort((a, b) => {
|
|
841
|
+
const ta = dayjs(String(a.obsDatetime ?? '')).valueOf() || 0;
|
|
842
|
+
const tb = dayjs(String(b.obsDatetime ?? '')).valueOf() || 0;
|
|
843
|
+
return tb - ta;
|
|
844
|
+
});
|
|
845
|
+
for (const obs of sorted) {
|
|
846
|
+
const cu = conceptUuidOf(obs);
|
|
847
|
+
if (cu && !map.has(cu)) {
|
|
848
|
+
map.set(cu, obs);
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
return map;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
function markFound(values: PreauthFormValues, key: PreauthFormFieldKey, present: boolean) {
|
|
855
|
+
if (present) values.found.add(key);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
function mapObsToPreauthFormValues(
|
|
859
|
+
obsList: Record<string, unknown>[],
|
|
860
|
+
source: PreauthFormValues['source'],
|
|
861
|
+
surgeryDateFromEncounter?: string,
|
|
862
|
+
): PreauthFormValues {
|
|
863
|
+
const values = emptyPreauthFormValues(source);
|
|
864
|
+
const byConcept = latestObsByConcept(obsList);
|
|
865
|
+
const C = PREAUTH_FORM_CONCEPTS;
|
|
866
|
+
|
|
867
|
+
const clinical = obsTextValue(byConcept.get(C.clinicalIndication));
|
|
868
|
+
values.clinicalIndications = clinical;
|
|
869
|
+
markFound(values, 'clinicalIndications', Boolean(clinical));
|
|
870
|
+
|
|
871
|
+
const start = obsDateIso(byConcept.get(C.startDate));
|
|
872
|
+
values.startDate = start;
|
|
873
|
+
markFound(values, 'startDate', Boolean(start));
|
|
874
|
+
|
|
875
|
+
const sessions = obsNumericValue(byConcept.get(C.sessionNumber));
|
|
876
|
+
values.sessionsRequired = sessions;
|
|
877
|
+
// Keep "0" as a valid found value (Boolean("0") is true; avoid treating empty only).
|
|
878
|
+
markFound(values, 'sessionsRequired', sessions !== '');
|
|
879
|
+
|
|
880
|
+
const freqObs = byConcept.get(C.frequencyOfSessions);
|
|
881
|
+
const frequency = mapFrequencyFromObs(freqObs);
|
|
882
|
+
values.frequency = frequency;
|
|
883
|
+
markFound(values, 'frequency', Boolean(frequency));
|
|
884
|
+
|
|
885
|
+
const complaints: string[] = [];
|
|
886
|
+
for (const obs of obsList) {
|
|
887
|
+
if (conceptUuidOf(obs) !== C.complaint) continue;
|
|
888
|
+
const uuid = codedUuid(obs.value);
|
|
889
|
+
const label =
|
|
890
|
+
COMPLAINT_CONCEPT_TO_LABEL[uuid] || codedDisplay(obs.value) || obsTextValue(obs);
|
|
891
|
+
if (label) complaints.push(label);
|
|
892
|
+
}
|
|
893
|
+
for (const obs of obsList) {
|
|
894
|
+
if (conceptUuidOf(obs) !== C.otherComplaint) continue;
|
|
895
|
+
const other = obsTextValue(obs);
|
|
896
|
+
if (other) complaints.push(other);
|
|
897
|
+
}
|
|
898
|
+
values.chiefComplaint = [...new Set(complaints)].join('; ');
|
|
899
|
+
markFound(values, 'chiefComplaint', Boolean(values.chiefComplaint));
|
|
900
|
+
|
|
901
|
+
const hpi = obsTextValue(byConcept.get(C.hpi));
|
|
902
|
+
values.hpi = hpi;
|
|
903
|
+
markFound(values, 'hpi', Boolean(hpi));
|
|
904
|
+
|
|
905
|
+
const exam = obsTextValue(byConcept.get(C.generalExam));
|
|
906
|
+
values.physicalExam = exam;
|
|
907
|
+
markFound(values, 'physicalExam', Boolean(exam));
|
|
908
|
+
|
|
909
|
+
const inv = obsTextValue(byConcept.get(C.investigation));
|
|
910
|
+
values.investigations = inv;
|
|
911
|
+
markFound(values, 'investigations', Boolean(inv));
|
|
912
|
+
|
|
913
|
+
const anaObs = byConcept.get(C.anaesthesia);
|
|
914
|
+
const anaUuid = codedUuid(anaObs?.value);
|
|
915
|
+
const anaesthesia = ANAESTHESIA_CONCEPT_TO_HIE[anaUuid] ?? '';
|
|
916
|
+
values.anaesthesia = anaesthesia;
|
|
917
|
+
markFound(values, 'anaesthesia', Boolean(anaesthesia));
|
|
918
|
+
|
|
919
|
+
if (surgeryDateFromEncounter) {
|
|
920
|
+
values.surgeryDate = surgeryDateFromEncounter;
|
|
921
|
+
markFound(values, 'surgeryDate', true);
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
const emp = obsYesNo(byConcept.get(C.employmentRelated));
|
|
925
|
+
values.relatedToEmployment = emp;
|
|
926
|
+
markFound(values, 'relatedToEmployment', emp !== null);
|
|
927
|
+
|
|
928
|
+
const acc = obsYesNo(byConcept.get(C.accidentRelated));
|
|
929
|
+
values.relatedToAccident = acc;
|
|
930
|
+
markFound(values, 'relatedToAccident', acc !== null);
|
|
931
|
+
|
|
932
|
+
const co = obsYesNo(byConcept.get(C.coInsured));
|
|
933
|
+
values.isCoInsured = co;
|
|
934
|
+
markFound(values, 'isCoInsured', co !== null);
|
|
935
|
+
|
|
936
|
+
const coDetails = obsTextValue(byConcept.get(C.coInsuredDetails));
|
|
937
|
+
values.coInsuranceDetails = coDetails;
|
|
938
|
+
markFound(values, 'coInsuranceDetails', Boolean(coDetails));
|
|
939
|
+
|
|
940
|
+
return values;
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
async function fetchLatestObsForConcept(
|
|
944
|
+
patientUuid: string,
|
|
945
|
+
conceptUuid: string,
|
|
946
|
+
): Promise<Record<string, unknown>[]> {
|
|
947
|
+
try {
|
|
948
|
+
const qs = new URLSearchParams({
|
|
949
|
+
patient: patientUuid,
|
|
950
|
+
concept: conceptUuid,
|
|
951
|
+
v: 'custom:(uuid,obsDatetime,concept:(uuid),value,valueText,valueDate,valueDatetime,groupMembers:(uuid,obsDatetime,concept:(uuid),value,valueText))',
|
|
952
|
+
limit: '50',
|
|
953
|
+
});
|
|
954
|
+
const res = await openmrsFetch(`${restBaseUrl}/obs?${qs.toString()}`);
|
|
955
|
+
return (res?.data?.results ?? []) as Record<string, unknown>[];
|
|
956
|
+
} catch {
|
|
957
|
+
return [];
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
async function fetchLatestPreauthEncounter(patientUuid: string): Promise<Record<string, unknown> | null> {
|
|
962
|
+
try {
|
|
963
|
+
const qs = new URLSearchParams({
|
|
964
|
+
patient: patientUuid,
|
|
965
|
+
encounterType: PREAUTH_ENCOUNTER_TYPE_UUID,
|
|
966
|
+
v: 'full',
|
|
967
|
+
limit: '20',
|
|
968
|
+
});
|
|
969
|
+
const res = await openmrsFetch(`${restBaseUrl}/encounter?${qs.toString()}`);
|
|
970
|
+
const results = (res?.data?.results ?? []) as Record<string, unknown>[];
|
|
971
|
+
if (!results.length) return null;
|
|
972
|
+
const sorted = [...results].sort((a, b) => {
|
|
973
|
+
const ta = dayjs(String(a.encounterDatetime ?? '')).valueOf() || 0;
|
|
974
|
+
const tb = dayjs(String(b.encounterDatetime ?? '')).valueOf() || 0;
|
|
975
|
+
return tb - ta;
|
|
976
|
+
});
|
|
977
|
+
let encounter = sorted[0] ?? null;
|
|
978
|
+
if (!encounter) return null;
|
|
979
|
+
|
|
980
|
+
// List endpoints sometimes omit nested obs even with v=full — reload by uuid.
|
|
981
|
+
const obs = encounter.obs;
|
|
982
|
+
if (!Array.isArray(obs) || obs.length === 0) {
|
|
983
|
+
const id = String(encounter.uuid ?? '');
|
|
984
|
+
if (id) {
|
|
985
|
+
try {
|
|
986
|
+
const full = await openmrsFetch(`${restBaseUrl}/encounter/${id}?v=full`);
|
|
987
|
+
if (full?.data && typeof full.data === 'object') {
|
|
988
|
+
encounter = full.data as Record<string, unknown>;
|
|
989
|
+
}
|
|
990
|
+
} catch {
|
|
991
|
+
// keep list representation
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
return encounter;
|
|
996
|
+
} catch {
|
|
997
|
+
return null;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Prefill values from POC Pre-authorization Form:
|
|
1003
|
+
* 1) latest PREAUTHORIZATION encounter obs
|
|
1004
|
+
* 2) else latest obs per concept
|
|
1005
|
+
*/
|
|
1006
|
+
export async function fetchPreauthFormValues(patientUuid: string): Promise<PreauthFormValues> {
|
|
1007
|
+
const uuid = (patientUuid ?? '').trim();
|
|
1008
|
+
if (!uuid) return emptyPreauthFormValues('none');
|
|
1009
|
+
|
|
1010
|
+
const encounter = await fetchLatestPreauthEncounter(uuid);
|
|
1011
|
+
if (encounter) {
|
|
1012
|
+
const obs = flattenObs(Array.isArray(encounter.obs) ? encounter.obs : []);
|
|
1013
|
+
const surgeryRaw = String(encounter.encounterDatetime ?? '');
|
|
1014
|
+
const surgeryDate = dayjs(surgeryRaw).isValid()
|
|
1015
|
+
? dayjs(surgeryRaw).format('YYYY-MM-DDTHH:mm:ssZ')
|
|
1016
|
+
: '';
|
|
1017
|
+
const fromEncounter = mapObsToPreauthFormValues(obs, 'encounter', surgeryDate);
|
|
1018
|
+
if (fromEncounter.found.size > 0) {
|
|
1019
|
+
return fromEncounter;
|
|
1020
|
+
}
|
|
1021
|
+
// Encounter present but no mappable obs — fall through to per-concept latest
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
const conceptList = [
|
|
1025
|
+
PREAUTH_FORM_CONCEPTS.clinicalIndication,
|
|
1026
|
+
PREAUTH_FORM_CONCEPTS.startDate,
|
|
1027
|
+
PREAUTH_FORM_CONCEPTS.sessionNumber,
|
|
1028
|
+
PREAUTH_FORM_CONCEPTS.frequencyOfSessions,
|
|
1029
|
+
PREAUTH_FORM_CONCEPTS.complaintGroup,
|
|
1030
|
+
PREAUTH_FORM_CONCEPTS.complaint,
|
|
1031
|
+
PREAUTH_FORM_CONCEPTS.otherComplaint,
|
|
1032
|
+
PREAUTH_FORM_CONCEPTS.hpi,
|
|
1033
|
+
PREAUTH_FORM_CONCEPTS.generalExam,
|
|
1034
|
+
PREAUTH_FORM_CONCEPTS.investigation,
|
|
1035
|
+
PREAUTH_FORM_CONCEPTS.anaesthesia,
|
|
1036
|
+
PREAUTH_FORM_CONCEPTS.employmentRelated,
|
|
1037
|
+
PREAUTH_FORM_CONCEPTS.accidentRelated,
|
|
1038
|
+
PREAUTH_FORM_CONCEPTS.coInsured,
|
|
1039
|
+
PREAUTH_FORM_CONCEPTS.coInsuredDetails,
|
|
1040
|
+
];
|
|
1041
|
+
|
|
1042
|
+
const batches = await Promise.all(conceptList.map((c) => fetchLatestObsForConcept(uuid, c)));
|
|
1043
|
+
const allObs = flattenObs(batches.flat());
|
|
1044
|
+
if (!allObs.length) return emptyPreauthFormValues(encounter ? 'encounter' : 'none');
|
|
1045
|
+
return mapObsToPreauthFormValues(allObs, 'obs');
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
/**
|
|
1049
|
+
* Latest OpenMRS obs for the clinical-indications concept for a patient.
|
|
1050
|
+
* Soft-fails to '' if missing or the request errors.
|
|
1051
|
+
*/
|
|
1052
|
+
export async function fetchLatestClinicalIndicationsObs(patientUuid: string): Promise<string> {
|
|
1053
|
+
const values = await fetchPreauthFormValues(patientUuid);
|
|
1054
|
+
return values.clinicalIndications;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/** Reusable preauth status check — prefer these over calling getPreauthPreview directly. */
|
|
1058
|
+
export {
|
|
1059
|
+
checkPreauthStatus,
|
|
1060
|
+
usePreauthPreview,
|
|
1061
|
+
isPreauthFinalised,
|
|
1062
|
+
isPreauthTerminalFailure,
|
|
1063
|
+
isPreauthNeedsClarification,
|
|
1064
|
+
isPreauthResubmittable,
|
|
1065
|
+
interventionHasBlockingPreauth,
|
|
1066
|
+
interventionHasFailedPreauth,
|
|
1067
|
+
interventionAllowsPreauthResubmit,
|
|
1068
|
+
invalidatePreauthPreview,
|
|
1069
|
+
preauthPreviewSwrKey,
|
|
1070
|
+
type PreauthCheckKind,
|
|
1071
|
+
type PreauthCheckResult,
|
|
1072
|
+
} from '../../../../claims/claims.resource';
|