@ampath/esm-dha-workflow-app 4.0.0-next.43 → 4.0.0-next.445
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 +47 -0
- package/dist/1100.js +1 -0
- package/dist/1100.js.map +1 -0
- package/dist/{197.js → 1197.js} +1 -1
- package/dist/1371.js +2 -0
- package/dist/1371.js.LICENSE.txt +282 -0
- package/dist/1371.js.map +1 -0
- package/dist/1435.js +1 -0
- package/dist/1435.js.map +1 -0
- package/dist/1673.js +1 -0
- package/dist/1673.js.map +1 -0
- package/dist/1843.js +1 -0
- package/dist/1843.js.map +1 -0
- package/dist/1931.js +1 -0
- package/dist/1931.js.map +1 -0
- package/dist/2272.js +2 -0
- package/dist/2272.js.map +1 -0
- package/dist/2383.js +1 -0
- package/dist/2383.js.map +1 -0
- package/dist/2439.js +1 -0
- package/dist/2439.js.map +1 -0
- package/dist/2535.js +1 -0
- package/dist/2535.js.map +1 -0
- package/dist/2592.js +1 -0
- package/dist/2592.js.map +1 -0
- package/dist/2632.js +1 -0
- package/dist/2632.js.map +1 -0
- package/dist/2635.js +1 -0
- package/dist/2635.js.map +1 -0
- package/dist/2663.js +1 -0
- package/dist/2663.js.map +1 -0
- package/dist/2687.js +1 -0
- package/dist/2687.js.map +1 -0
- package/dist/2802.js +1 -0
- package/dist/2802.js.map +1 -0
- package/dist/2808.js +1 -0
- package/dist/2808.js.map +1 -0
- package/dist/282.js +1 -1
- package/dist/282.js.LICENSE.txt +3 -3
- package/dist/282.js.map +1 -1
- package/dist/2848.js +1 -0
- package/dist/2848.js.map +1 -0
- package/dist/3.js +1 -0
- package/dist/3.js.map +1 -0
- package/dist/3016.js +1 -0
- package/dist/3016.js.map +1 -0
- package/dist/3041.js +1 -0
- package/dist/3041.js.map +1 -0
- package/dist/3099.js +1 -0
- package/dist/3182.js +1 -0
- package/dist/3182.js.map +1 -0
- package/dist/3184.js +2 -0
- package/dist/3184.js.map +1 -0
- package/dist/3196.js +1 -0
- package/dist/3196.js.map +1 -0
- package/dist/3242.js +1 -0
- package/dist/3242.js.map +1 -0
- package/dist/3270.js +1 -0
- package/dist/3270.js.map +1 -0
- package/dist/3288.js +1 -0
- package/dist/3288.js.map +1 -0
- package/dist/3311.js +2 -0
- package/dist/3311.js.LICENSE.txt +9 -0
- package/dist/3311.js.map +1 -0
- package/dist/3558.js +1 -0
- package/dist/3558.js.map +1 -0
- package/dist/3612.js +1 -0
- package/dist/3612.js.map +1 -0
- package/dist/3636.js +1 -0
- package/dist/3636.js.map +1 -0
- package/dist/3654.js +1 -0
- package/dist/3654.js.map +1 -0
- package/dist/3794.js +1 -0
- package/dist/3794.js.map +1 -0
- package/dist/3816.js +1 -0
- package/dist/3816.js.map +1 -0
- package/dist/3897.js +1 -0
- package/dist/3897.js.map +1 -0
- package/dist/3949.js +1 -0
- package/dist/3949.js.map +1 -0
- package/dist/4055.js +1 -0
- package/dist/408.js +1 -0
- package/dist/408.js.map +1 -0
- package/dist/409.js +1 -0
- package/dist/409.js.map +1 -0
- package/dist/411.js +1 -0
- package/dist/411.js.map +1 -0
- package/dist/4225.js +1 -0
- package/dist/4225.js.map +1 -0
- package/dist/4300.js +1 -0
- package/dist/{335.js → 4335.js} +1 -1
- package/dist/4353.js +1 -0
- package/dist/4353.js.map +1 -0
- package/dist/4399.js +1 -0
- package/dist/4399.js.map +1 -0
- package/dist/4569.js +1 -0
- package/dist/4569.js.map +1 -0
- package/dist/{652.js → 4652.js} +1 -1
- package/dist/474.js +1 -0
- package/dist/474.js.map +1 -0
- package/dist/4993.js +1 -0
- package/dist/4993.js.map +1 -0
- package/dist/5006.js +1 -0
- package/dist/5006.js.map +1 -0
- package/dist/5119.js +1 -0
- package/dist/5119.js.map +1 -0
- package/dist/5138.js +1 -0
- package/dist/5138.js.map +1 -0
- package/dist/5179.js +1 -0
- package/dist/5179.js.map +1 -0
- package/dist/5244.js +1 -0
- package/dist/5244.js.map +1 -0
- package/dist/5353.js +1 -0
- package/dist/5353.js.map +1 -0
- package/dist/5377.js +1 -0
- package/dist/5377.js.map +1 -0
- package/dist/5413.js +1 -0
- package/dist/5413.js.map +1 -0
- package/dist/5422.js +1 -0
- package/dist/5422.js.map +1 -0
- package/dist/5500.js +1 -0
- package/dist/5500.js.map +1 -0
- package/dist/5754.js +1 -0
- package/dist/5754.js.map +1 -0
- package/dist/5805.js +1 -0
- package/dist/5805.js.map +1 -0
- package/dist/6048.js +1 -0
- package/dist/6048.js.map +1 -0
- package/dist/6055.js +1 -0
- package/dist/6055.js.map +1 -0
- package/dist/6206.js +1 -0
- package/dist/6206.js.map +1 -0
- package/dist/6279.js +1 -0
- package/dist/6279.js.map +1 -0
- package/dist/6399.js +1 -0
- package/dist/6399.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/6682.js +1 -0
- package/dist/6682.js.map +1 -0
- package/dist/6802.js +1 -0
- package/dist/6802.js.map +1 -0
- package/dist/7024.js +1 -0
- package/dist/7024.js.map +1 -0
- package/dist/72.js +1 -0
- package/dist/72.js.map +1 -0
- package/dist/7269.js +1 -0
- package/dist/7269.js.map +1 -0
- package/dist/7332.js +1 -0
- package/dist/7332.js.map +1 -0
- package/dist/7369.js +1 -0
- package/dist/7369.js.map +1 -0
- package/dist/7593.js +1 -0
- package/dist/7593.js.map +1 -0
- package/dist/7694.js +1 -0
- package/dist/7694.js.map +1 -0
- package/dist/7698.js +1 -0
- package/dist/7698.js.map +1 -0
- package/dist/7734.js +1 -0
- package/dist/7734.js.map +1 -0
- package/dist/774.js +1 -0
- package/dist/774.js.map +1 -0
- package/dist/7852.js +1 -0
- package/dist/7852.js.map +1 -0
- package/dist/7949.js +2 -0
- package/dist/{246.js.LICENSE.txt → 7949.js.LICENSE.txt} +1 -10
- package/dist/7949.js.map +1 -0
- package/dist/7958.js +1 -0
- package/dist/7958.js.map +1 -0
- package/dist/8137.js +1 -0
- package/dist/8137.js.map +1 -0
- package/dist/8167.js +1 -0
- package/dist/8167.js.map +1 -0
- package/dist/818.js +1 -0
- package/dist/818.js.map +1 -0
- package/dist/8250.js +1 -0
- package/dist/8250.js.map +1 -0
- package/dist/8308.js +1 -0
- package/dist/8308.js.map +1 -0
- package/dist/8735.js +1 -0
- package/dist/8735.js.map +1 -0
- package/dist/8947.js +1 -0
- package/dist/8947.js.map +1 -0
- package/dist/8961.js +1 -0
- package/dist/8961.js.map +1 -0
- package/dist/902.js +1 -0
- package/dist/902.js.map +1 -0
- package/dist/9062.js +1 -0
- package/dist/9062.js.map +1 -0
- package/dist/9134.js +1 -0
- package/dist/9134.js.map +1 -0
- package/dist/9249.js +1 -0
- package/dist/9249.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/9429.js +1 -0
- package/dist/9429.js.map +1 -0
- package/dist/9442.js +1 -0
- package/dist/9442.js.map +1 -0
- package/dist/961.js +1 -1
- package/dist/961.js.map +1 -1
- package/dist/968.js +1 -0
- package/dist/968.js.map +1 -0
- package/dist/9709.js +1 -0
- package/dist/9709.js.map +1 -0
- package/dist/9768.js +1 -0
- package/dist/9768.js.map +1 -0
- package/dist/9770.js +1 -0
- package/dist/9770.js.map +1 -0
- package/dist/9879.js +1 -0
- package/dist/9879.js.map +1 -0
- package/dist/9974.js +1 -0
- package/dist/9974.js.map +1 -0
- package/dist/esm-dha-workflow-app.js +1 -1
- package/dist/esm-dha-workflow-app.js.buildmanifest.json +2284 -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/jest.config.js +4 -0
- package/local-config.json +9 -0
- package/package.json +29 -11
- 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 +268 -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 +220 -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/admin/claims/claims-list.component.scss +13 -0
- package/src/billing/admin/claims/claims-list.component.tsx +163 -0
- package/src/billing/admin/claims-admin-dashboard.component.scss +0 -0
- package/src/billing/admin/claims-admin-dashboard.component.tsx +32 -0
- package/src/billing/api/billing.api.ts +139 -0
- package/src/billing/billing-claims.resource.ts +1112 -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 +37 -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-and-claims-patient-chart.component.tsx +52 -0
- package/src/billing/dashboard/v2/billing-claims-dashboard.component.scss +221 -0
- package/src/billing/dashboard/v2/billing-claims-dashboard.component.tsx +342 -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 +293 -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-list/claim-visits.component.scss +28 -0
- package/src/billing/dashboard/v2/claim-visits/claim-list/claim-visits.component.tsx +315 -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/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 +280 -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 +67 -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 +660 -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 +145 -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 +199 -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 +688 -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 +130 -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 +382 -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 +234 -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/death-notification.component.tsx +162 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/death-notification.resource.ts +112 -0
- package/src/billing/dashboard/v2/patient-bill-details/attachments/death-notification.scss +88 -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 +450 -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 +187 -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 +234 -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 +123 -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 +241 -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 +1032 -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 +53 -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 +534 -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 +40 -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 +268 -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 +103 -0
- package/src/billing/dashboard/v3/claim-visits/claim-visit-details/claim-visit-details.component.tsx +519 -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/identify-emergency-unknown-patient/identify-emergencu-unknown-patient.scss +407 -0
- package/src/billing/dashboard/v3/claim-visits/modal/identify-emergency-unknown-patient/identify-emergency-unknown-patient.component.tsx +523 -0
- package/src/billing/dashboard/v3/claim-visits/modal/identify-emergency-unknown-patient/identify-patient-helper.ts +77 -0
- package/src/billing/dashboard/v3/claim-visits/modal/submit-claim/submit-claim.modal.tsx +280 -0
- package/src/billing/dashboard/v3/claim-visits/modal/submit-emergency-claim/submit-emergency-claim.component.tsx +91 -0
- package/src/billing/dashboard/v3/claim-visits/modal/submit-emergency-claim/submit-emergency.scss +14 -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 +171 -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 +644 -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/claims-stats-dashboard/claim-stat/claim-stat.component.scss +27 -0
- package/src/billing/dashboard/v3/claims-stats-dashboard/claim-stat/claim-stat.component.tsx +41 -0
- package/src/billing/dashboard/v3/claims-stats-dashboard/claims-stats-dashboard.component.scss +16 -0
- package/src/billing/dashboard/v3/claims-stats-dashboard/claims-stats-dashboard.component.tsx +184 -0
- package/src/billing/dashboard/v3/claims-stats-dashboard/modal/claim-stats-list/claim-stats-list.modal.scss +0 -0
- package/src/billing/dashboard/v3/claims-stats-dashboard/modal/claim-stats-list/claim-stats-list.modal.tsx +27 -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 +92 -0
- package/src/billing/dashboard/v3/facility-bills/facility-bills.component.tsx +306 -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 +127 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/add-attachments.component.tsx +228 -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 +287 -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 +352 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/dialysis/dialysis-helper.ts +117 -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 +450 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/invoice.component.tsx +151 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/invoice.scss +225 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/lab-results/lab-orders.component.tsx +198 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/lab-results/lab-orders.scss +227 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/medical-report/medical-report.component.tsx +346 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/medical-report/medical-report.scss +265 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/proforma-invoice/proforma-invoice.component.tsx +347 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/proforma-invoice/proforma-invoice.scss +285 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/type.ts +280 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/ultrasound-report/ultrasound-report.scss +273 -0
- package/src/billing/dashboard/v3/patient-bill-details/attachments/ultrasound-report/utlrasound-report.component.tsx +435 -0
- package/src/billing/dashboard/v3/patient-bill-details/bill-details/bill-details.scss +17 -0
- package/src/billing/dashboard/v3/patient-bill-details/bill-details/bill-details.tsx +377 -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 +71 -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 +156 -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 +137 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/claim-details/claim-details.modal.scss +28 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/claim-details/claim-details.modal.tsx +170 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/pomsf/pomsf-scheme-balance.util.test.ts +56 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/pomsf/pomsf-scheme-balance.util.ts +27 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/pomsf/set-effective-pomsf-coverage.component.tsx +128 -0
- package/src/billing/dashboard/v3/patient-bill-details/modals/pomsf/set-effective-pomsf-coverage.scss +27 -0
- package/src/billing/dashboard/v3/patient-bill-details/patient-bill-details.scss +85 -0
- package/src/billing/dashboard/v3/patient-bill-details/patient-bill-details.tsx +363 -0
- package/src/billing/dashboard/v3/patient-bill-details/patient-visit-details.tsx +256 -0
- package/src/billing/dashboard/v3/patient-bill-details/patient-visit.scss +9 -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 +102 -0
- package/src/billing/dashboard/v3/preauth/elective/elective-authorize.resource.ts +284 -0
- package/src/billing/dashboard/v3/preauth/elective/elective-preauth-request.workspace.scss +125 -0
- package/src/billing/dashboard/v3/preauth/elective/elective-preauth-request.workspace.tsx +1184 -0
- package/src/billing/dashboard/v3/preauth/elective/elective-preauth.component.scss +15 -0
- package/src/billing/dashboard/v3/preauth/elective/elective-preauth.component.tsx +377 -0
- package/src/billing/dashboard/v3/preauth/elective/elective-preauth.resource.ts +1378 -0
- package/src/billing/dashboard/v3/preauth/elective/elective-requests-list.component.tsx +357 -0
- package/src/billing/dashboard/v3/preauth/preauth-attachments.component.tsx +388 -0
- package/src/billing/dashboard/v3/preauth/preauth-list.component.scss +34 -0
- package/src/billing/dashboard/v3/preauth/preauth-list.component.tsx +300 -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 +1549 -0
- package/src/billing/dashboard/v3/preauth/preauth.workspace.scss +176 -0
- package/src/billing/dashboard/v3/preauth/preauth.workspace.tsx +2458 -0
- package/src/billing/dashboard/v3/preauth/preauthorizations-tab.component.tsx +55 -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 +450 -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 +514 -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/reports/billing-and-claims-reports-dashboard.scss +40 -0
- package/src/billing/reports/billing-and-claims-reports-dashboard.tsx +32 -0
- package/src/billing/reports/claims/claims-report-dashboard.scss +55 -0
- package/src/billing/reports/claims/claims-report-dashboard.tsx +136 -0
- package/src/billing/reports/claims/summary-data/summary-data.scss +24 -0
- package/src/billing/reports/claims/summary-data/summary-data.tsx +184 -0
- package/src/billing/types/index.ts +411 -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 +223 -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 +874 -0
- package/src/billing/workspaces/create-order-bill-form-workspace/schema.ts +20 -0
- package/src/billing/workspaces/create-order-bill-form-workspace/types.ts +49 -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 +743 -0
- package/src/claims/claims.resource.ts +1855 -0
- package/src/claims/index.ts +365 -0
- package/src/claims/interventions.resource.ts +131 -0
- package/src/claims/utils.ts +64 -0
- package/src/config-schema.ts +264 -0
- package/src/context/patient-context.tsx +27 -0
- package/src/critical-care-unit/critical-care-root.tsx +23 -0
- package/src/critical-care-unit/hdu/hdu-queues.component.scss +7 -0
- package/src/critical-care-unit/hdu/hdu-queues.component.tsx +31 -0
- package/src/critical-care-unit/hdu/queues/consultation/hdu-consultation.tsx +18 -0
- package/src/critical-care-unit/icu/icu-queues.component.scss +7 -0
- package/src/critical-care-unit/icu/icu-queues.component.tsx +31 -0
- package/src/critical-care-unit/icu/queues/consultation/icu-consultation.tsx +17 -0
- package/src/critical-care-unit/icu-burns/icu-burns-queues.component.scss +7 -0
- package/src/critical-care-unit/icu-burns/icu-burns-queues.component.tsx +30 -0
- package/src/critical-care-unit/icu-burns/queues/consultation/icu-burns-consultation.tsx +17 -0
- package/src/critical-care-unit/nicu/nicu-queues.component.scss +7 -0
- package/src/critical-care-unit/nicu/nicu-queues.component.tsx +31 -0
- package/src/critical-care-unit/nicu/queues/consultation/nicu-consultation.tsx +17 -0
- package/src/critical-care-unit/picu/picu-queues.component.scss +7 -0
- package/src/critical-care-unit/picu/picu-queues.component.tsx +31 -0
- package/src/critical-care-unit/picu/queues/consultation/picu-consultation.tsx +17 -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 +29 -38
- package/src/dashboard/overview/overview.component.scss +40 -59
- package/src/dashboard/overview/overview.component.tsx +55 -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/claims-admin.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/elective-preauth.meta.ts +6 -0
- package/src/dashboard-meta/emt-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/registers-dashboard.meta.ts +6 -0
- package/src/{registry-dashboard.meta.ts → dashboard-meta/registry-dashboard.meta.ts} +2 -2
- package/src/dashboard-meta/service-queue-admin.meta.ts +6 -0
- package/src/dashboard-meta/shr-dashboard.meta.ts +19 -0
- package/src/dashboard-meta/specialized-clinics-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/telemedicine-dashboard.meta.ts +6 -0
- package/src/dashboard-meta/telemedicine-patient-chart.meta.ts +6 -0
- package/src/dashboard-meta/triage-dashboard.meta.ts +6 -0
- package/src/death-reporting/death-reporting-form-button.component.tsx +50 -0
- package/src/death-reporting/death-reporting-form-button.resource.ts +64 -0
- package/src/emt/cr-lookup.resource.test.ts +88 -0
- package/src/emt/cr-lookup.resource.ts +42 -0
- package/src/emt/emt-queue.component.test.tsx +353 -0
- package/src/emt/emt-queue.component.tsx +463 -0
- package/src/emt/emt-queue.scss +85 -0
- package/src/emt/emt.resource.test.ts +247 -0
- package/src/emt/emt.resource.ts +150 -0
- package/src/emt/handover-modal/handover-modal.component.test.tsx +273 -0
- package/src/emt/handover-modal/handover-modal.component.tsx +538 -0
- package/src/emt/handover-modal/handover-modal.scss +113 -0
- package/src/emt/types/emt.types.ts +137 -0
- package/src/index.ts +236 -10
- 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/{mch → mnch/mch}/queues/consultation/mch-consultation.tsx +2 -2
- package/src/{mch → mnch/mch}/queues/triage/mch-triage.tsx +2 -2
- package/src/mnch/mnch-root.tsx +17 -0
- package/src/mortuary/mortuary.component.tsx +2 -2
- 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 +116 -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 +1542 -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/emergency/emergency-extension.component.tsx +599 -0
- package/src/registry/emergency/emergency-helper.ts +47 -0
- package/src/registry/emergency/emergency.resource.ts +291 -0
- package/src/registry/emergency/emergency.scss +123 -0
- package/src/registry/emergency/otp-component.tsx +289 -0
- package/src/registry/emergency/type/index.ts +77 -0
- package/src/registry/emergency/unidentified/unidentified-registration.component.tsx +154 -0
- package/src/registry/emergency/unidentified/unidentified-registration.scss +0 -0
- package/src/registry/emergency/unidentified/unidentified.component.tsx +376 -0
- package/src/registry/emergency/unidentified/unidentified.scss +0 -0
- package/src/registry/hie.resource.ts +481 -0
- package/src/registry/hie.types.ts +63 -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 +809 -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 +130 -0
- package/src/registry/modal/otp-verification-modal/otp-verification-modal.scss +15 -3
- package/src/registry/modal/otp-verification-modal/otp-verification-modal.tsx +136 -44
- 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 +991 -0
- package/src/registry/modal/send-to-triage/send-to-queue.workspace.tsx +24 -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 +1086 -130
- 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 +732 -220
- package/src/registry/registry.resource.ts +22 -3
- package/src/registry/types/index.ts +126 -9
- 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 +7 -4
- 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 +7 -2
- package/src/resources/queue.resource.ts +3 -3
- package/src/resources/superset.resource.ts +41 -0
- package/src/resources/visit.resource.ts +19 -1
- package/src/root.component.tsx +9 -7
- package/src/routes.json +658 -30
- 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 +193 -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 +201 -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 +35 -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 +296 -60
- 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 +293 -2
- package/src/service-queues/service.resource.ts +1 -1
- package/src/shared/constants/concepts.ts +70 -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 +9 -0
- package/src/shared/services/billable-service.resource.ts +121 -0
- package/src/shared/services/billing.resource.ts +112 -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/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 +12 -12
- package/src/shared/ui/otp-input/otp-input.component.tsx +13 -6
- package/src/{service-queues/service-queue/stats → shared/ui}/stat-card/stat-card.component.tsx +6 -3
- package/src/shared/utils/format-title-case.ts +8 -0
- package/src/shared/utils/get-base-url.ts +15 -0
- package/src/shared/utils/get-tag-type.ts +75 -0
- package/src/shr/shr-close-visit-form.component.tsx +102 -0
- package/src/shr/shr-code-systems.json +363 -0
- package/src/shr/shr-terminology.resource.test.ts +66 -0
- package/src/shr/shr-terminology.resource.ts +64 -0
- package/src/shr/shr-viewer/shr-categories.test.ts +241 -0
- package/src/shr/shr-viewer/shr-categories.ts +209 -0
- package/src/shr/shr-viewer/shr-presentation.test.ts +511 -0
- package/src/shr/shr-viewer/shr-presentation.ts +883 -0
- package/src/shr/shr-viewer/shr-viewer.component.test.tsx +176 -0
- package/src/shr/shr-viewer/shr-viewer.component.tsx +432 -0
- package/src/shr/shr-viewer/shr-viewer.scss +239 -0
- package/src/shr/shr-visit-sync.test.ts +88 -0
- package/src/shr/shr-visit-sync.ts +62 -0
- package/src/shr/shr.component.tsx +730 -0
- package/src/shr/shr.resource.test.ts +737 -0
- package/src/shr/shr.resource.ts +463 -0
- package/src/shr/shr.scss +114 -0
- package/src/shr/shr.types.ts +682 -0
- package/src/shr/workspaces/shr-consent-workspace/schema.ts +53 -0
- package/src/shr/workspaces/shr-consent-workspace/shr-consent.scss +71 -0
- package/src/shr/workspaces/shr-consent-workspace/shr-consent.workspace.tsx +686 -0
- package/src/side-nav-menu/accounting-nav-link-config.ts +16 -0
- package/src/side-nav-menu/accounting-nav-links.tsx +42 -0
- package/src/side-nav-menu/critical-care-nav-links.tsx +42 -0
- package/src/side-nav-menu/critical-care-unit-nav-link-config.ts +28 -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 +5 -5
- package/src/side-nav-menu/specialized-clinics-nav-link-config.ts +32 -0
- package/src/side-nav-menu/specialized-clinics-nav-links.tsx +42 -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 +25 -0
- package/src/telemedicine/telemedicine-patient-chart.component.test.tsx +123 -0
- package/src/telemedicine/telemedicine-patient-chart.component.tsx +131 -0
- package/src/telemedicine/telemedicine.component.test.tsx +113 -0
- package/src/telemedicine/telemedicine.component.tsx +310 -0
- package/src/telemedicine/telemedicine.resource.test.ts +171 -0
- package/src/telemedicine/telemedicine.resource.ts +125 -0
- package/src/telemedicine/telemedicine.scss +91 -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/tools/fetch-shr-code-systems.mjs +135 -0
- package/tools/strip-openmrs-declaration-maps.mjs +44 -0
- package/tools/update-openmrs-deps.mjs +36 -5
- package/translations/en.json +135 -0
- package/tsconfig.json +7 -4
- package/webpack.config.js +74 -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/246.js +0 -2
- package/dist/246.js.map +0 -1
- package/dist/255.js +0 -1
- package/dist/255.js.map +0 -1
- package/dist/28.js +0 -1
- package/dist/28.js.map +0 -1
- package/dist/300.js +0 -1
- package/dist/327.js +0 -1
- package/dist/327.js.map +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/619.js +0 -1
- package/dist/619.js.map +0 -1
- package/dist/65.js +0 -1
- package/dist/65.js.map +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.LICENSE.txt +0 -14
- 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/93.js +0 -1
- package/dist/93.js.map +0 -1
- package/dist/99.js +0 -1
- /package/dist/{104.js.LICENSE.txt → 2272.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/src/{pharmacy-dashboard.meta.ts → dashboard-meta/pharmacy-dashboard.meta.ts} +0 -0
- /package/src/{queue-dashboard.meta.ts → dashboard-meta/queue-dashboard.meta.ts} +0 -0
- /package/src/{service-queues/service-queue/stats → shared/ui}/stat-card/stat-card.component.scss +0 -0
|
@@ -0,0 +1,1378 @@
|
|
|
1
|
+
import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import {
|
|
4
|
+
createPreauthRequest,
|
|
5
|
+
extractPreauthStatusForIntervention,
|
|
6
|
+
fetchShaInterventionByCode,
|
|
7
|
+
getPreauthPreview,
|
|
8
|
+
getServiceType,
|
|
9
|
+
listPreAuthRequests,
|
|
10
|
+
patchPreAuthRequest,
|
|
11
|
+
type ListPreAuthRequestsParams,
|
|
12
|
+
} from '../../../../../claims/claims.resource';
|
|
13
|
+
import {
|
|
14
|
+
fetchPatientDiagnosesForBilling,
|
|
15
|
+
preferredDiagnosisForPreauth,
|
|
16
|
+
} from '../../../../billing-claims.resource';
|
|
17
|
+
import type { Intervention, PreAuthRequestRecord, PreauthRequest } from '../../../../../claims/index';
|
|
18
|
+
import type { AmrsVisitDiagnosis } from '../../../../types';
|
|
19
|
+
import { IdentifierTypesUuids } from '../../../../../resources/identifier-types';
|
|
20
|
+
import { createOrderEncounter, getOrder } from '../../../../../shared/services/encounters.resource';
|
|
21
|
+
import type { CreateOrderEncounterDto } from '../../../../../shared/types';
|
|
22
|
+
import {
|
|
23
|
+
CLINICAL_INDICATIONS_CONCEPT_UUID,
|
|
24
|
+
fetchPreauthFormValues,
|
|
25
|
+
PREAUTH_ENCOUNTER_TYPE_UUID,
|
|
26
|
+
PREAUTH_FORM_CONCEPTS,
|
|
27
|
+
PREAUTH_INTERVENTION_TYPE,
|
|
28
|
+
searchDiagnosisConcepts,
|
|
29
|
+
type DiagnosisConceptHit,
|
|
30
|
+
} from '../preauth.resource';
|
|
31
|
+
|
|
32
|
+
type ConceptMappingLike = {
|
|
33
|
+
display?: string;
|
|
34
|
+
conceptReferenceTerm?: {
|
|
35
|
+
code?: string;
|
|
36
|
+
name?: string;
|
|
37
|
+
conceptSource?: { uuid?: string; name?: string; hl7Code?: string };
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type ElectiveConceptOption = {
|
|
42
|
+
uuid: string;
|
|
43
|
+
display: string;
|
|
44
|
+
/** Mappings from dictionary search — SHA code is resolved only after selection. */
|
|
45
|
+
mappings?: ConceptMappingLike[];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** SHA concept source name in OpenMRS (reference term source). */
|
|
49
|
+
export const SHA_CONCEPT_SOURCE = 'SHA';
|
|
50
|
+
|
|
51
|
+
/** Extract intervention code from mappings whose concept source is SHA. */
|
|
52
|
+
export function extractShaCodeFromConcept(concept: {
|
|
53
|
+
mappings?: ConceptMappingLike[];
|
|
54
|
+
}): string {
|
|
55
|
+
for (const m of concept.mappings ?? []) {
|
|
56
|
+
const term = m.conceptReferenceTerm;
|
|
57
|
+
if (!term) continue;
|
|
58
|
+
const sourceName = String(term.conceptSource?.name ?? '').trim();
|
|
59
|
+
if (sourceName.toUpperCase() !== SHA_CONCEPT_SOURCE) continue;
|
|
60
|
+
const code = String(term.code ?? '').trim().toUpperCase();
|
|
61
|
+
if (code) return code.startsWith('SHA') ? code : `SHA-${code}`;
|
|
62
|
+
}
|
|
63
|
+
for (const m of concept.mappings ?? []) {
|
|
64
|
+
const display = String(m.display ?? '');
|
|
65
|
+
// e.g. "SHA: SHA-06-031" or "SHA: 06-031"
|
|
66
|
+
if (!/^SHA\s*:/i.test(display) && !display.toUpperCase().startsWith('SHA:')) continue;
|
|
67
|
+
const match = display.match(/SHA-\d[\w-]*/i) ?? display.split(':').pop()?.trim();
|
|
68
|
+
if (match) {
|
|
69
|
+
const code = String(match).trim().toUpperCase();
|
|
70
|
+
return code.startsWith('SHA') ? code : `SHA-${code}`;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const CONCEPT_SEARCH_REPR =
|
|
77
|
+
'custom:(uuid,display,mappings:(display,conceptReferenceTerm:(uuid,code,name,conceptSource:(uuid,name,hl7Code))))';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Search the OpenMRS concept dictionary (name / code).
|
|
81
|
+
* Results are concepts with mappings attached; SHA code is read on select.
|
|
82
|
+
*/
|
|
83
|
+
export async function searchElectiveConcepts(q: string): Promise<ElectiveConceptOption[]> {
|
|
84
|
+
const term = (q ?? '').trim();
|
|
85
|
+
if (term.length < 2) {
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const params = new URLSearchParams({
|
|
90
|
+
q: term,
|
|
91
|
+
limit: '25',
|
|
92
|
+
v: CONCEPT_SEARCH_REPR,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
try {
|
|
96
|
+
const response = await openmrsFetch(`${restBaseUrl}/concept?${params.toString()}`);
|
|
97
|
+
const results =
|
|
98
|
+
(response?.data?.results as Array<{
|
|
99
|
+
uuid: string;
|
|
100
|
+
display: string;
|
|
101
|
+
mappings?: ConceptMappingLike[];
|
|
102
|
+
}>) ?? [];
|
|
103
|
+
|
|
104
|
+
const out: ElectiveConceptOption[] = [];
|
|
105
|
+
const seen = new Set<string>();
|
|
106
|
+
for (const c of results) {
|
|
107
|
+
if (!c?.uuid || seen.has(c.uuid)) continue;
|
|
108
|
+
seen.add(c.uuid);
|
|
109
|
+
out.push({
|
|
110
|
+
uuid: c.uuid,
|
|
111
|
+
display: c.display || c.uuid,
|
|
112
|
+
mappings: c.mappings ?? [],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
116
|
+
} catch {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export async function fetchPatientCrNumber(
|
|
122
|
+
patientUuid: string,
|
|
123
|
+
identifierTypeUuid: string,
|
|
124
|
+
): Promise<string> {
|
|
125
|
+
if (!patientUuid || !identifierTypeUuid) return '';
|
|
126
|
+
try {
|
|
127
|
+
const res = await openmrsFetch(
|
|
128
|
+
`${restBaseUrl}/patient/${patientUuid}?v=custom:(uuid,identifiers:(identifier,identifierType:(uuid)))`,
|
|
129
|
+
);
|
|
130
|
+
const identifiers = (res?.data?.identifiers ?? []) as Array<{
|
|
131
|
+
identifier?: string;
|
|
132
|
+
identifierType?: { uuid?: string };
|
|
133
|
+
}>;
|
|
134
|
+
const hit = identifiers.find((i) => i.identifierType?.uuid === identifierTypeUuid);
|
|
135
|
+
return String(hit?.identifier ?? '').trim();
|
|
136
|
+
} catch {
|
|
137
|
+
return '';
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export type ElectiveDiagnosisOption = {
|
|
142
|
+
key: string;
|
|
143
|
+
conceptUuid: string;
|
|
144
|
+
display: string;
|
|
145
|
+
icd11Code: string;
|
|
146
|
+
rank?: number | null;
|
|
147
|
+
source: 'visit' | 'search';
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export type ElectiveCaptureInput = {
|
|
151
|
+
patientUuid: string;
|
|
152
|
+
locationUuid: string;
|
|
153
|
+
encounterTypeUuid: string;
|
|
154
|
+
concept: ElectiveConceptOption;
|
|
155
|
+
intervention: Intervention;
|
|
156
|
+
clinicalIndications: string;
|
|
157
|
+
expectedServiceStartDate: string;
|
|
158
|
+
chiefComplaint?: string;
|
|
159
|
+
hpi?: string;
|
|
160
|
+
physicalExam?: string;
|
|
161
|
+
investigations?: string;
|
|
162
|
+
anaesthesia?: string;
|
|
163
|
+
surgeryDate?: string;
|
|
164
|
+
relatedToEmployment?: boolean;
|
|
165
|
+
relatedToAccident?: boolean;
|
|
166
|
+
isCoInsured?: boolean;
|
|
167
|
+
coInsuranceDetails?: string;
|
|
168
|
+
sessionsRequired?: string;
|
|
169
|
+
frequency?: string;
|
|
170
|
+
startDate?: string;
|
|
171
|
+
necessity?: string;
|
|
172
|
+
lensPrescription?: string;
|
|
173
|
+
newOrReplacement?: string;
|
|
174
|
+
lensAmount?: string;
|
|
175
|
+
eyeExamAmount?: string;
|
|
176
|
+
frameAmount?: string;
|
|
177
|
+
/** Primary diagnosis on the preauth encounter (UI field; preferably prefilled from today’s visit) */
|
|
178
|
+
diagnosis?: ElectiveDiagnosisOption | null;
|
|
179
|
+
/** Session / selected provider — stored on the encounter for Accounting Raise */
|
|
180
|
+
providerUuid?: string;
|
|
181
|
+
/** Optional override; otherwise Clinician/Unknown role is resolved from OpenMRS */
|
|
182
|
+
encounterRoleUuid?: string;
|
|
183
|
+
/** ISO datetime for encounter */
|
|
184
|
+
encounterDatetime?: string;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/** OpenMRS core default "Unknown" encounter role — fallback if lookup fails. */
|
|
188
|
+
const DEFAULT_ENCOUNTER_ROLE_UUID = 'a0b03050-c99b-11e0-9572-0800200c9a66';
|
|
189
|
+
|
|
190
|
+
const HIE_ANAESTHESIA_TO_CONCEPT: Record<string, string> = {
|
|
191
|
+
GENERAL: '7a69a31a-d88f-4ebd-a00b-cb5b4581de00',
|
|
192
|
+
LOCAL: '074225d4-b1be-56e9-93f6-255ebf106df3',
|
|
193
|
+
SEDATION: '3fa5c3a8-41e5-493a-9ab7-7177fc6f8c82',
|
|
194
|
+
SPINAL: 'f45ac884-e73e-4b02-9d8b-49c4e3ce5a15',
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const HIE_FREQUENCY_TO_CONCEPT: Record<string, string> = {
|
|
198
|
+
ONCE_A_WEEK: '5dcfe297-2ef7-4f1c-97e3-a519c18fcc84',
|
|
199
|
+
TWICE_A_WEEK: '6f4a4c5b-34d4-4577-b1f2-c0e5d5a61374',
|
|
200
|
+
ONCE_EVERY_2_WEEKS: '690b2ab2-4cbc-4df4-be19-64b8a93981ab',
|
|
201
|
+
ONCE_EVERY_3_WEEKS: '72ec1de0-4bf0-4c40-9329-b8f574a64132',
|
|
202
|
+
ONCE_A_MONTH: 'a899d7f6-1350-11df-a1f1-0026b9348838',
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const LENS_TO_CONCEPT: Record<string, string> = {
|
|
206
|
+
FRAMES_LENSES: '51fc8b51-c35d-4025-9d25-fef5d0d44b47',
|
|
207
|
+
FRAMED: '51fc8b51-c35d-4025-9d25-fef5d0d44b47',
|
|
208
|
+
CONTACT: 'da45c81a-e0fc-4589-8094-cb6fb7a7a285',
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const NEW_OR_REPL_TO_CONCEPT: Record<string, string> = {
|
|
212
|
+
NEW: 'a8a48066-1350-11df-a1f1-0026b9348838',
|
|
213
|
+
REPLACEMENT: 'f021d384-65cd-47b5-b96c-6dc738a00452',
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
function interventionTypeConcept(intervention: Intervention): string {
|
|
217
|
+
const flags = {
|
|
218
|
+
requiresSurgicalPreauth: Boolean(intervention.requiresSurgicalPreauth),
|
|
219
|
+
requiresRenalPreauth: Boolean(intervention.requiresRenalPreauth),
|
|
220
|
+
requiresOncologyPreauth: Boolean(intervention.requiresOncologyPreauth),
|
|
221
|
+
requiresRadiologyPreauth: Boolean(intervention.requiresRadiologyPreauth),
|
|
222
|
+
requiresOpticalPreauth: Boolean(intervention.requiresOpticalPreauth),
|
|
223
|
+
};
|
|
224
|
+
if (flags.requiresSurgicalPreauth) return PREAUTH_INTERVENTION_TYPE.surgical;
|
|
225
|
+
if (flags.requiresRenalPreauth) return PREAUTH_INTERVENTION_TYPE.renal;
|
|
226
|
+
if (flags.requiresOncologyPreauth) return PREAUTH_INTERVENTION_TYPE.oncology;
|
|
227
|
+
if (flags.requiresRadiologyPreauth) return PREAUTH_INTERVENTION_TYPE.imaging;
|
|
228
|
+
if (flags.requiresOpticalPreauth) return PREAUTH_INTERVENTION_TYPE.optical;
|
|
229
|
+
return PREAUTH_INTERVENTION_TYPE.normal;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
let cachedEncounterRoleUuid: string | null = null;
|
|
233
|
+
|
|
234
|
+
async function resolveEncounterRoleUuid(configured?: string): Promise<string> {
|
|
235
|
+
const fromConfig = (configured ?? '').trim();
|
|
236
|
+
if (fromConfig) return fromConfig;
|
|
237
|
+
if (cachedEncounterRoleUuid) return cachedEncounterRoleUuid;
|
|
238
|
+
|
|
239
|
+
try {
|
|
240
|
+
const res = await openmrsFetch(
|
|
241
|
+
`${restBaseUrl}/encounterrole?v=custom:(uuid,display,retired)&limit=50`,
|
|
242
|
+
);
|
|
243
|
+
const results = (res?.data?.results ?? []) as Array<{
|
|
244
|
+
uuid?: string;
|
|
245
|
+
display?: string;
|
|
246
|
+
retired?: boolean;
|
|
247
|
+
}>;
|
|
248
|
+
const active = results.filter((r) => r.uuid && !r.retired);
|
|
249
|
+
const preferred =
|
|
250
|
+
active.find((r) => /clinician/i.test(String(r.display ?? ''))) ||
|
|
251
|
+
active.find((r) => /unknown/i.test(String(r.display ?? ''))) ||
|
|
252
|
+
active[0];
|
|
253
|
+
if (preferred?.uuid) {
|
|
254
|
+
cachedEncounterRoleUuid = preferred.uuid;
|
|
255
|
+
return preferred.uuid;
|
|
256
|
+
}
|
|
257
|
+
} catch {
|
|
258
|
+
// fall through to default
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
cachedEncounterRoleUuid = DEFAULT_ENCOUNTER_ROLE_UUID;
|
|
262
|
+
return DEFAULT_ENCOUNTER_ROLE_UUID;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
function plannedServiceObsConcept(configured?: string): string {
|
|
266
|
+
const fromConfig = (configured ?? '').trim();
|
|
267
|
+
// Only persist as encounter obs when a real Text concept UUID is configured.
|
|
268
|
+
return fromConfig;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function buildObs(
|
|
272
|
+
input: ElectiveCaptureInput,
|
|
273
|
+
plannedServiceObsConceptUuid?: string,
|
|
274
|
+
): Array<Record<string, unknown>> {
|
|
275
|
+
const C = PREAUTH_FORM_CONCEPTS;
|
|
276
|
+
const obs: Array<Record<string, unknown>> = [];
|
|
277
|
+
const text = (concept: string, value?: string) => {
|
|
278
|
+
const v = (value ?? '').trim();
|
|
279
|
+
if (!v || !concept) return;
|
|
280
|
+
obs.push({ concept, value: v });
|
|
281
|
+
};
|
|
282
|
+
const coded = (concept: string, valueConcept?: string) => {
|
|
283
|
+
const v = (valueConcept ?? '').trim();
|
|
284
|
+
if (!v || !concept) return;
|
|
285
|
+
obs.push({ concept, value: v });
|
|
286
|
+
};
|
|
287
|
+
const boolCoded = (concept: string, value?: boolean) => {
|
|
288
|
+
if (value === undefined) return;
|
|
289
|
+
coded(concept, value ? C.yes : C.no);
|
|
290
|
+
};
|
|
291
|
+
const dateObs = (concept: string, iso?: string) => {
|
|
292
|
+
if (!iso) return;
|
|
293
|
+
const d = dayjs(iso);
|
|
294
|
+
if (!d.isValid()) return;
|
|
295
|
+
obs.push({ concept, value: d.format('YYYY-MM-DDTHH:mm:ss.SSSZZ') });
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
obs.push({
|
|
299
|
+
concept: C.typeOfIntervention,
|
|
300
|
+
value: interventionTypeConcept(input.intervention),
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
text(C.clinicalIndication || CLINICAL_INDICATIONS_CONCEPT_UUID, input.clinicalIndications);
|
|
304
|
+
dateObs(C.expectedServiceStartDate || C.startDate, input.expectedServiceStartDate);
|
|
305
|
+
// Free-text chief complaint → "Specify other complaints" concept.
|
|
306
|
+
text(C.otherComplaint, input.chiefComplaint);
|
|
307
|
+
text(C.hpi, input.hpi);
|
|
308
|
+
text(C.generalExam, input.physicalExam);
|
|
309
|
+
text(C.investigation, input.investigations);
|
|
310
|
+
|
|
311
|
+
if (input.anaesthesia) {
|
|
312
|
+
coded(C.anaesthesia, HIE_ANAESTHESIA_TO_CONCEPT[input.anaesthesia] || input.anaesthesia);
|
|
313
|
+
}
|
|
314
|
+
// Surgery date is not a dedicated form concept — reuse startDate when surgical.
|
|
315
|
+
dateObs(C.startDate, input.surgeryDate || input.startDate);
|
|
316
|
+
|
|
317
|
+
boolCoded(C.employmentRelated, input.relatedToEmployment);
|
|
318
|
+
boolCoded(C.accidentRelated, input.relatedToAccident);
|
|
319
|
+
boolCoded(C.coInsured, input.isCoInsured);
|
|
320
|
+
text(C.coInsuredDetails, input.coInsuranceDetails);
|
|
321
|
+
|
|
322
|
+
if (input.sessionsRequired?.trim()) {
|
|
323
|
+
obs.push({ concept: C.sessionNumber, value: Number(input.sessionsRequired) });
|
|
324
|
+
}
|
|
325
|
+
if (input.frequency) {
|
|
326
|
+
coded(C.frequencyOfSessions, HIE_FREQUENCY_TO_CONCEPT[input.frequency] || input.frequency);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
if (input.lensPrescription) {
|
|
330
|
+
coded(C.lens, LENS_TO_CONCEPT[input.lensPrescription] || input.lensPrescription);
|
|
331
|
+
}
|
|
332
|
+
if (input.newOrReplacement) {
|
|
333
|
+
coded(C.newRequest, NEW_OR_REPL_TO_CONCEPT[input.newOrReplacement] || input.newOrReplacement);
|
|
334
|
+
}
|
|
335
|
+
if (input.lensAmount?.trim()) {
|
|
336
|
+
obs.push({ concept: C.lensAmount, value: Number(input.lensAmount) });
|
|
337
|
+
}
|
|
338
|
+
if (input.eyeExamAmount?.trim()) {
|
|
339
|
+
obs.push({ concept: C.eyeExaminationAmount, value: Number(input.eyeExamAmount) });
|
|
340
|
+
}
|
|
341
|
+
if (input.frameAmount?.trim()) {
|
|
342
|
+
obs.push({ concept: C.frameAmount, value: Number(input.frameAmount) });
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Planned orderable concept UUID (text) — used later by Create Order.
|
|
346
|
+
const orderableUuid = (input.concept?.uuid ?? '').trim();
|
|
347
|
+
if (orderableUuid) {
|
|
348
|
+
text(plannedServiceObsConcept(plannedServiceObsConceptUuid), orderableUuid);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return obs;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/** Form question concept UUIDs we manage on elective capture (void these on edit). */
|
|
355
|
+
function electiveManagedConceptUuids(plannedServiceObsConceptUuid?: string): Set<string> {
|
|
356
|
+
const C = PREAUTH_FORM_CONCEPTS;
|
|
357
|
+
return new Set(
|
|
358
|
+
[
|
|
359
|
+
C.typeOfIntervention,
|
|
360
|
+
C.clinicalIndication,
|
|
361
|
+
CLINICAL_INDICATIONS_CONCEPT_UUID,
|
|
362
|
+
C.startDate,
|
|
363
|
+
C.expectedServiceStartDate,
|
|
364
|
+
C.otherComplaint,
|
|
365
|
+
C.hpi,
|
|
366
|
+
C.generalExam,
|
|
367
|
+
C.investigation,
|
|
368
|
+
C.anaesthesia,
|
|
369
|
+
C.employmentRelated,
|
|
370
|
+
C.accidentRelated,
|
|
371
|
+
C.coInsured,
|
|
372
|
+
C.coInsuredDetails,
|
|
373
|
+
C.sessionNumber,
|
|
374
|
+
C.frequencyOfSessions,
|
|
375
|
+
C.lens,
|
|
376
|
+
C.newRequest,
|
|
377
|
+
C.lensAmount,
|
|
378
|
+
C.eyeExaminationAmount,
|
|
379
|
+
C.frameAmount,
|
|
380
|
+
C.plannedServiceConcept,
|
|
381
|
+
plannedServiceObsConcept(plannedServiceObsConceptUuid),
|
|
382
|
+
].filter(Boolean),
|
|
383
|
+
);
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export async function createElectivePreauthEncounter(
|
|
387
|
+
input: ElectiveCaptureInput & { plannedServiceObsConceptUuid?: string },
|
|
388
|
+
): Promise<{ uuid: string }> {
|
|
389
|
+
const encounterType = input.encounterTypeUuid || PREAUTH_ENCOUNTER_TYPE_UUID;
|
|
390
|
+
const providerUuid = (input.providerUuid ?? '').trim();
|
|
391
|
+
if (!providerUuid) {
|
|
392
|
+
throw new Error('A provider is required to save the elective preauth encounter');
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const encounterRole = await resolveEncounterRoleUuid(input.encounterRoleUuid);
|
|
396
|
+
const diagnosisConceptUuid = (input.diagnosis?.conceptUuid ?? '').trim();
|
|
397
|
+
const body: Record<string, unknown> = {
|
|
398
|
+
patient: input.patientUuid,
|
|
399
|
+
encounterType,
|
|
400
|
+
location: input.locationUuid,
|
|
401
|
+
encounterDatetime: input.encounterDatetime || dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZZ'),
|
|
402
|
+
encounterProviders: [
|
|
403
|
+
{
|
|
404
|
+
provider: providerUuid,
|
|
405
|
+
encounterRole,
|
|
406
|
+
},
|
|
407
|
+
],
|
|
408
|
+
obs: buildObs(input, input.plannedServiceObsConceptUuid),
|
|
409
|
+
// OpenMRS 2.2+ encounter resource — same shape as GET encounter.diagnoses
|
|
410
|
+
diagnoses: diagnosisConceptUuid
|
|
411
|
+
? [
|
|
412
|
+
{
|
|
413
|
+
patient: input.patientUuid,
|
|
414
|
+
rank: Number(input.diagnosis?.rank) > 0 ? Number(input.diagnosis?.rank) : 1,
|
|
415
|
+
certainty: 'CONFIRMED',
|
|
416
|
+
diagnosis: {
|
|
417
|
+
coded: diagnosisConceptUuid,
|
|
418
|
+
},
|
|
419
|
+
},
|
|
420
|
+
]
|
|
421
|
+
: [],
|
|
422
|
+
};
|
|
423
|
+
const res = await openmrsFetch(`${restBaseUrl}/encounter`, {
|
|
424
|
+
method: 'POST',
|
|
425
|
+
headers: { 'Content-Type': 'application/json' },
|
|
426
|
+
body,
|
|
427
|
+
});
|
|
428
|
+
const uuid = String(res?.data?.uuid ?? '');
|
|
429
|
+
if (!uuid) {
|
|
430
|
+
throw new Error('Failed to create preauth encounter');
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return { uuid };
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export type ElectiveEncounterObsProps = {
|
|
437
|
+
uuid: string;
|
|
438
|
+
conceptUuid: string;
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
export type ElectiveEncounterEditModel = {
|
|
442
|
+
encounterUuid: string;
|
|
443
|
+
hold: PreAuthRequestRecord | null;
|
|
444
|
+
formValues: Awaited<ReturnType<typeof fetchPreauthFormValues>>;
|
|
445
|
+
plannedConcept: ElectiveConceptOption | null;
|
|
446
|
+
existingObs: ElectiveEncounterObsProps[];
|
|
447
|
+
diagnoses: ElectiveDiagnosisOption[];
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Load an elective preauth encounter for edit — form obs, planned orderable concept, hold.
|
|
452
|
+
*/
|
|
453
|
+
export async function loadElectiveEncounterForEdit(
|
|
454
|
+
encounterUuid: string,
|
|
455
|
+
patientUuid: string,
|
|
456
|
+
plannedServiceObsConceptUuid?: string,
|
|
457
|
+
): Promise<ElectiveEncounterEditModel> {
|
|
458
|
+
const encUuid = (encounterUuid ?? '').trim();
|
|
459
|
+
if (!encUuid) {
|
|
460
|
+
throw new Error('Missing encounter UUID');
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
const res = await openmrsFetch(
|
|
464
|
+
`${restBaseUrl}/encounter/${encUuid}?v=custom:(uuid,encounterDatetime,diagnoses:(uuid,display,rank,certainty,diagnosis:(coded:(uuid,display))),obs:(uuid,voided,concept:(uuid,display),value,valueText,valueCodedName))`,
|
|
465
|
+
);
|
|
466
|
+
const enc = res?.data as Record<string, unknown> | undefined;
|
|
467
|
+
if (!enc?.uuid) {
|
|
468
|
+
throw new Error('Encounter not found');
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const obsList = (Array.isArray(enc.obs) ? enc.obs : []) as Array<Record<string, unknown>>;
|
|
472
|
+
const existingObs: ElectiveEncounterObsProps[] = [];
|
|
473
|
+
for (const o of obsList) {
|
|
474
|
+
if (o.voided) continue;
|
|
475
|
+
const ou = String(o.uuid ?? '').trim();
|
|
476
|
+
const cu = conceptUuid(o);
|
|
477
|
+
if (ou && cu) existingObs.push({ uuid: ou, conceptUuid: cu });
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
const plannedQ = plannedServiceObsConcept(plannedServiceObsConceptUuid);
|
|
481
|
+
let plannedConceptUuid =
|
|
482
|
+
obsText(obsList.find((o) => !o.voided && conceptUuid(o) === plannedQ)) || '';
|
|
483
|
+
|
|
484
|
+
let hold: PreAuthRequestRecord | null = null;
|
|
485
|
+
try {
|
|
486
|
+
const holds = await fetchElectiveHolds({ encounterUuid: encUuid });
|
|
487
|
+
hold = holds[0] ?? null;
|
|
488
|
+
} catch {
|
|
489
|
+
hold = null;
|
|
490
|
+
}
|
|
491
|
+
if (!plannedConceptUuid) {
|
|
492
|
+
plannedConceptUuid = plannedConceptUuidFromOrderNo(hold?.orderNo);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
let plannedConcept: ElectiveConceptOption | null = null;
|
|
496
|
+
if (plannedConceptUuid) {
|
|
497
|
+
try {
|
|
498
|
+
const conceptRes = await openmrsFetch(
|
|
499
|
+
`${restBaseUrl}/concept/${plannedConceptUuid}?v=${encodeURIComponent(CONCEPT_SEARCH_REPR)}`,
|
|
500
|
+
);
|
|
501
|
+
const c = conceptRes?.data as ElectiveConceptOption | undefined;
|
|
502
|
+
if (c?.uuid) {
|
|
503
|
+
plannedConcept = {
|
|
504
|
+
uuid: c.uuid,
|
|
505
|
+
display: String(c.display ?? c.uuid),
|
|
506
|
+
mappings: c.mappings,
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
} catch {
|
|
510
|
+
plannedConcept = {
|
|
511
|
+
uuid: plannedConceptUuid,
|
|
512
|
+
display: plannedConceptUuid,
|
|
513
|
+
mappings: [],
|
|
514
|
+
};
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
const formValues = await fetchPreauthFormValues(patientUuid, encUuid);
|
|
519
|
+
|
|
520
|
+
const diagnoses: ElectiveDiagnosisOption[] = [];
|
|
521
|
+
const dxList = (Array.isArray(enc.diagnoses) ? enc.diagnoses : []) as Array<Record<string, unknown>>;
|
|
522
|
+
for (const dx of dxList) {
|
|
523
|
+
const diagnosis = (dx.diagnosis ?? {}) as Record<string, unknown>;
|
|
524
|
+
const coded = diagnosis.coded as { uuid?: string; display?: string } | string | undefined;
|
|
525
|
+
const conceptUuidDx =
|
|
526
|
+
typeof coded === 'object' ? String(coded?.uuid ?? '').trim() : String(coded ?? '').trim();
|
|
527
|
+
const display =
|
|
528
|
+
(typeof coded === 'object' ? String(coded?.display ?? '').trim() : '') ||
|
|
529
|
+
String(dx.display ?? '').trim() ||
|
|
530
|
+
conceptUuidDx;
|
|
531
|
+
if (!conceptUuidDx) continue;
|
|
532
|
+
diagnoses.push({
|
|
533
|
+
key: `enc-dx-${conceptUuidDx}`,
|
|
534
|
+
conceptUuid: conceptUuidDx,
|
|
535
|
+
display,
|
|
536
|
+
icd11Code: '',
|
|
537
|
+
rank: typeof dx.rank === 'number' ? dx.rank : Number(dx.rank) || 1,
|
|
538
|
+
source: 'visit',
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
return {
|
|
543
|
+
encounterUuid: encUuid,
|
|
544
|
+
hold,
|
|
545
|
+
formValues,
|
|
546
|
+
plannedConcept,
|
|
547
|
+
existingObs,
|
|
548
|
+
diagnoses,
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Update elective preauth encounter obs via OpenMRS void-and-replace:
|
|
554
|
+
* same `obs` array includes `{ uuid, voided: true }` for current rows and new obs without uuid.
|
|
555
|
+
*/
|
|
556
|
+
export async function updateElectivePreauthEncounter(
|
|
557
|
+
encounterUuid: string,
|
|
558
|
+
input: ElectiveCaptureInput & { plannedServiceObsConceptUuid?: string },
|
|
559
|
+
existingObs: ElectiveEncounterObsProps[],
|
|
560
|
+
): Promise<{ uuid: string }> {
|
|
561
|
+
const encUuid = (encounterUuid ?? '').trim();
|
|
562
|
+
if (!encUuid) {
|
|
563
|
+
throw new Error('Missing encounter UUID');
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
const newObs = buildObs(input, input.plannedServiceObsConceptUuid);
|
|
567
|
+
const managed = electiveManagedConceptUuids(input.plannedServiceObsConceptUuid);
|
|
568
|
+
const voided = existingObs
|
|
569
|
+
.filter((o) => managed.has(o.conceptUuid))
|
|
570
|
+
.map((o) => ({ uuid: o.uuid, voided: true as const }));
|
|
571
|
+
|
|
572
|
+
const body = {
|
|
573
|
+
obs: [...voided, ...newObs],
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
const res = await openmrsFetch(`${restBaseUrl}/encounter/${encUuid}`, {
|
|
577
|
+
method: 'POST',
|
|
578
|
+
headers: { 'Content-Type': 'application/json' },
|
|
579
|
+
body,
|
|
580
|
+
});
|
|
581
|
+
const uuid = String(res?.data?.uuid ?? encUuid);
|
|
582
|
+
if (!uuid) {
|
|
583
|
+
throw new Error('Failed to update preauth encounter');
|
|
584
|
+
}
|
|
585
|
+
return { uuid };
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** Update hold orderNo concept encoding when the orderable concept changes (before a real order #). */
|
|
589
|
+
export async function syncElectiveHoldOrderConcept(opts: {
|
|
590
|
+
holdId: number;
|
|
591
|
+
encounterUuid: string;
|
|
592
|
+
conceptUuid: string;
|
|
593
|
+
currentOrderNo?: string | null;
|
|
594
|
+
}): Promise<void> {
|
|
595
|
+
const current = String(opts.currentOrderNo ?? '').trim();
|
|
596
|
+
// Do not overwrite a real OpenMRS order number.
|
|
597
|
+
if (current && !current.startsWith('ELECTIVE-')) {
|
|
598
|
+
return;
|
|
599
|
+
}
|
|
600
|
+
const next = opts.conceptUuid
|
|
601
|
+
? `ELECTIVE-${opts.encounterUuid}::${opts.conceptUuid}`
|
|
602
|
+
: `ELECTIVE-${opts.encounterUuid}`;
|
|
603
|
+
if (next === current) return;
|
|
604
|
+
await patchPreAuthRequest(opts.holdId, { orderNo: next });
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
function diagnosisOptionFromConcept(hit: DiagnosisConceptHit): ElectiveDiagnosisOption {
|
|
608
|
+
return {
|
|
609
|
+
key: `search-${hit.uuid}`,
|
|
610
|
+
conceptUuid: hit.uuid,
|
|
611
|
+
display: hit.display,
|
|
612
|
+
icd11Code: hit.icd11Code,
|
|
613
|
+
rank: 1,
|
|
614
|
+
source: 'search',
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
function diagnosisOptionFromVisitDx(dx: AmrsVisitDiagnosis): ElectiveDiagnosisOption | null {
|
|
619
|
+
const icd11Code = String(dx.icd11_code ?? '').trim();
|
|
620
|
+
const conceptUuid = String(dx.uuid ?? '').trim();
|
|
621
|
+
// ETL uuid is usually the coded concept uuid for encounter-diagnosis rows.
|
|
622
|
+
if (!conceptUuid && !icd11Code) return null;
|
|
623
|
+
const display = icd11Code
|
|
624
|
+
? `${icd11Code} · ${dx.concept_source_name || dx.encounter_type || 'Visit diagnosis'}`
|
|
625
|
+
: dx.concept_source_name || dx.encounter_type || conceptUuid;
|
|
626
|
+
return {
|
|
627
|
+
key: `visit-${dx.encounter_id}-${icd11Code || conceptUuid}`,
|
|
628
|
+
conceptUuid,
|
|
629
|
+
display,
|
|
630
|
+
icd11Code,
|
|
631
|
+
rank: dx.dx_rank ?? null,
|
|
632
|
+
source: 'visit',
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
async function ensureDiagnosisConceptUuid(
|
|
637
|
+
option: ElectiveDiagnosisOption,
|
|
638
|
+
): Promise<ElectiveDiagnosisOption> {
|
|
639
|
+
if (option.conceptUuid) return option;
|
|
640
|
+
const code = (option.icd11Code ?? '').trim();
|
|
641
|
+
if (!code) return option;
|
|
642
|
+
try {
|
|
643
|
+
const hits = await searchDiagnosisConcepts(code);
|
|
644
|
+
const match =
|
|
645
|
+
hits.find((h) => h.icd11Code.toUpperCase() === code.toUpperCase()) || hits[0];
|
|
646
|
+
if (match?.uuid) {
|
|
647
|
+
return {
|
|
648
|
+
...option,
|
|
649
|
+
conceptUuid: match.uuid,
|
|
650
|
+
display: option.display || match.display,
|
|
651
|
+
icd11Code: option.icd11Code || match.icd11Code,
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
} catch {
|
|
655
|
+
// keep unresolved
|
|
656
|
+
}
|
|
657
|
+
return option;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
/**
|
|
661
|
+
* Diagnoses from today's active visit encounters (OpenMRS) plus today's ETL diagnosis rows.
|
|
662
|
+
* Prefers rank-1 ICD-11 coded rows for prefill.
|
|
663
|
+
*/
|
|
664
|
+
export async function fetchTodaysVisitDiagnoses(
|
|
665
|
+
patientUuid: string,
|
|
666
|
+
locationUuid: string,
|
|
667
|
+
): Promise<{ options: ElectiveDiagnosisOption[]; preferred: ElectiveDiagnosisOption | null }> {
|
|
668
|
+
if (!patientUuid || !locationUuid) {
|
|
669
|
+
return { options: [], preferred: null };
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
const today = dayjs().format('YYYY-MM-DD');
|
|
673
|
+
const options: ElectiveDiagnosisOption[] = [];
|
|
674
|
+
const seen = new Set<string>();
|
|
675
|
+
|
|
676
|
+
const addOption = (opt: ElectiveDiagnosisOption | null) => {
|
|
677
|
+
if (!opt) return;
|
|
678
|
+
const key = `${opt.conceptUuid}|${opt.icd11Code}`.toUpperCase();
|
|
679
|
+
if (!opt.conceptUuid && !opt.icd11Code) return;
|
|
680
|
+
if (seen.has(key)) return;
|
|
681
|
+
seen.add(key);
|
|
682
|
+
options.push(opt);
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
// 1) Diagnoses already on encounters in today's active visit
|
|
686
|
+
try {
|
|
687
|
+
const params = new URLSearchParams({
|
|
688
|
+
patient: patientUuid,
|
|
689
|
+
includeInactive: 'false',
|
|
690
|
+
fromStartDate: dayjs().startOf('day').toISOString(),
|
|
691
|
+
location: locationUuid,
|
|
692
|
+
v: 'custom:(uuid,startDatetime,stopDatetime,encounters:(uuid,encounterDatetime,diagnoses:(uuid,display,rank,certainty,diagnosis:(coded:(uuid,display),nonCoded))))',
|
|
693
|
+
limit: '1',
|
|
694
|
+
});
|
|
695
|
+
const visitRes = await openmrsFetch(`${restBaseUrl}/visit?${params.toString()}`);
|
|
696
|
+
const visit = (visitRes?.data?.results ?? [])[0] as
|
|
697
|
+
| { encounters?: Array<Record<string, unknown>> }
|
|
698
|
+
| undefined;
|
|
699
|
+
const encounters = visit?.encounters ?? [];
|
|
700
|
+
for (const enc of encounters) {
|
|
701
|
+
const diagnoses = (Array.isArray(enc.diagnoses) ? enc.diagnoses : []) as Array<
|
|
702
|
+
Record<string, unknown>
|
|
703
|
+
>;
|
|
704
|
+
for (const dx of diagnoses) {
|
|
705
|
+
const diagnosis = (dx.diagnosis ?? dx.condition ?? {}) as Record<string, unknown>;
|
|
706
|
+
const coded = diagnosis.coded as { uuid?: string; display?: string } | string | undefined;
|
|
707
|
+
const conceptUuid =
|
|
708
|
+
typeof coded === 'object' ? String(coded?.uuid ?? '').trim() : String(coded ?? '').trim();
|
|
709
|
+
const display =
|
|
710
|
+
(typeof coded === 'object' ? String(coded?.display ?? '').trim() : '') ||
|
|
711
|
+
String(dx.display ?? '').trim() ||
|
|
712
|
+
conceptUuid;
|
|
713
|
+
if (!conceptUuid) continue;
|
|
714
|
+
addOption({
|
|
715
|
+
key: `visit-enc-${String(enc.uuid ?? '')}-${conceptUuid}`,
|
|
716
|
+
conceptUuid,
|
|
717
|
+
display,
|
|
718
|
+
icd11Code: '',
|
|
719
|
+
rank: typeof dx.rank === 'number' ? dx.rank : Number(dx.rank) || null,
|
|
720
|
+
source: 'visit',
|
|
721
|
+
});
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
} catch {
|
|
725
|
+
// continue with ETL
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
// 2) ETL visit / encounter / maternity diagnoses for today (adds ICD-11 codes)
|
|
729
|
+
let etlPreferred: AmrsVisitDiagnosis | null = null;
|
|
730
|
+
try {
|
|
731
|
+
const etlRows = await fetchPatientDiagnosesForBilling({
|
|
732
|
+
visitDate: today,
|
|
733
|
+
billingDate: today,
|
|
734
|
+
patientUuid,
|
|
735
|
+
locationUuid,
|
|
736
|
+
});
|
|
737
|
+
etlPreferred = preferredDiagnosisForPreauth(etlRows);
|
|
738
|
+
for (const row of etlRows) {
|
|
739
|
+
addOption(diagnosisOptionFromVisitDx(row));
|
|
740
|
+
}
|
|
741
|
+
} catch {
|
|
742
|
+
// keep OpenMRS-only options
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
// Resolve missing concept UUIDs via ICD-11 dictionary search
|
|
746
|
+
const resolved = await Promise.all(options.map((o) => ensureDiagnosisConceptUuid(o)));
|
|
747
|
+
const usable = resolved.filter((o) => o.conceptUuid);
|
|
748
|
+
|
|
749
|
+
let preferred: ElectiveDiagnosisOption | null = null;
|
|
750
|
+
if (etlPreferred) {
|
|
751
|
+
const fromEtl = diagnosisOptionFromVisitDx(etlPreferred);
|
|
752
|
+
if (fromEtl) {
|
|
753
|
+
const resolvedPreferred = await ensureDiagnosisConceptUuid(fromEtl);
|
|
754
|
+
if (resolvedPreferred.conceptUuid) {
|
|
755
|
+
preferred = resolvedPreferred;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
if (!preferred) {
|
|
760
|
+
preferred =
|
|
761
|
+
usable.find((o) => Number(o.rank) === 1) ||
|
|
762
|
+
usable[0] ||
|
|
763
|
+
null;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
return { options: usable, preferred };
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
export async function searchElectiveDiagnoses(q: string): Promise<ElectiveDiagnosisOption[]> {
|
|
770
|
+
const hits = await searchDiagnosisConcepts(q);
|
|
771
|
+
return hits.map(diagnosisOptionFromConcept);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
export async function holdElectivePreauthRequest(opts: {
|
|
775
|
+
patientUuid: string;
|
|
776
|
+
locationUuid: string;
|
|
777
|
+
encounterUuid: string;
|
|
778
|
+
intervention: Intervention;
|
|
779
|
+
expectedServiceStartDate: string;
|
|
780
|
+
conceptUuid?: string;
|
|
781
|
+
}): Promise<unknown> {
|
|
782
|
+
const code = (opts.intervention.code ?? '').trim();
|
|
783
|
+
const subBenefit =
|
|
784
|
+
(opts.intervention as Intervention & { packageCode?: string }).packageCode ||
|
|
785
|
+
code.split('-').slice(0, 2).join('-') ||
|
|
786
|
+
code;
|
|
787
|
+
|
|
788
|
+
const docs = (opts.intervention.applicableDocumentTypes ?? []).filter(Boolean).join(',');
|
|
789
|
+
const requiredDocs = (opts.intervention.requiredPreauthDocumentTypes ?? []).filter(Boolean).join(',');
|
|
790
|
+
|
|
791
|
+
const payload: PreauthRequest = {
|
|
792
|
+
patientUuid: opts.patientUuid,
|
|
793
|
+
locationUuid: opts.locationUuid,
|
|
794
|
+
encounterUuid: opts.encounterUuid,
|
|
795
|
+
expectedServiceStartDate: dayjs(opts.expectedServiceStartDate).toISOString(),
|
|
796
|
+
// Encode planned OpenMRS concept UUID for later Create Order (replaced by real order #).
|
|
797
|
+
orderNo: opts.conceptUuid
|
|
798
|
+
? `ELECTIVE-${opts.encounterUuid}::${opts.conceptUuid}`
|
|
799
|
+
: `ELECTIVE-${opts.encounterUuid}`,
|
|
800
|
+
subBenefitCode: subBenefit,
|
|
801
|
+
interventionCode: code,
|
|
802
|
+
serviceType: getServiceType(opts.intervention, 'OUTPATIENT'),
|
|
803
|
+
requiresPreauth: Boolean(opts.intervention.needsPreauth),
|
|
804
|
+
normalPreauth: Boolean(opts.intervention.needsPreauth) && !Boolean(opts.intervention.needsManualPreauthApproval),
|
|
805
|
+
electivePreauth: true,
|
|
806
|
+
applicableDocumentTypes: docs,
|
|
807
|
+
requiredPreauthDocumentTypes: requiredDocs,
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
return createPreauthRequest(payload);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
/** Parse planned service concept UUID from elective hold orderNo (`ELECTIVE-{enc}::{conceptUuid}`). */
|
|
814
|
+
export function plannedConceptUuidFromOrderNo(orderNo: string | null | undefined): string {
|
|
815
|
+
const raw = String(orderNo ?? '').trim();
|
|
816
|
+
const marker = '::';
|
|
817
|
+
const idx = raw.indexOf(marker);
|
|
818
|
+
if (idx < 0) return '';
|
|
819
|
+
return raw.slice(idx + marker.length).trim();
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/** Resolve OpenMRS concept UUID for an elective hold (orderNo encoding, then SHA dictionary match). */
|
|
823
|
+
export async function resolveElectiveServiceConceptUuid(opts: {
|
|
824
|
+
orderNo?: string | null;
|
|
825
|
+
interventionCode?: string | null;
|
|
826
|
+
}): Promise<string> {
|
|
827
|
+
const fromOrderNo = plannedConceptUuidFromOrderNo(opts.orderNo);
|
|
828
|
+
if (fromOrderNo) return fromOrderNo;
|
|
829
|
+
|
|
830
|
+
const code = String(opts.interventionCode ?? '').trim().toUpperCase();
|
|
831
|
+
if (!code) return '';
|
|
832
|
+
|
|
833
|
+
const searchTerms = [code, code.replace(/^SHA-/, ''), code.replace(/^SHA-/i, '')].filter(
|
|
834
|
+
(t, i, arr) => t.length >= 2 && arr.indexOf(t) === i,
|
|
835
|
+
);
|
|
836
|
+
for (const term of searchTerms) {
|
|
837
|
+
try {
|
|
838
|
+
const hits = await searchElectiveConcepts(term);
|
|
839
|
+
const exact = hits.find((h) => extractShaCodeFromConcept(h) === code);
|
|
840
|
+
if (exact?.uuid) return exact.uuid;
|
|
841
|
+
const fuzzy = hits.find((h) => extractShaCodeFromConcept(h).includes(code.replace(/^SHA-/, '')));
|
|
842
|
+
if (fuzzy?.uuid) return fuzzy.uuid;
|
|
843
|
+
} catch {
|
|
844
|
+
// try next term
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return '';
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
export async function resolveCoverageForConcept(
|
|
851
|
+
patientCr: string,
|
|
852
|
+
locationUuid: string,
|
|
853
|
+
shaCode: string,
|
|
854
|
+
): Promise<Intervention | null> {
|
|
855
|
+
return fetchShaInterventionByCode(patientCr, locationUuid, shaCode);
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
export async function fetchElectiveHolds(
|
|
859
|
+
params: ListPreAuthRequestsParams,
|
|
860
|
+
): Promise<PreAuthRequestRecord[]> {
|
|
861
|
+
return listPreAuthRequests({
|
|
862
|
+
...params,
|
|
863
|
+
electivePreauth: true,
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
type ElectiveHoldStatusSource = Pick<
|
|
868
|
+
PreAuthRequestRecord,
|
|
869
|
+
'id' | 'patientUuid' | 'interventionCode' | 'consentToken' | 'status' | 'locationUuid'
|
|
870
|
+
> & {
|
|
871
|
+
crNo?: string;
|
|
872
|
+
};
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Refresh HIE statuses for elective holds that already have a consent token.
|
|
876
|
+
* Holds without a token are ignored — callers must filter to raised rows only.
|
|
877
|
+
*/
|
|
878
|
+
export async function syncElectiveHoldStatusesFromPreview(
|
|
879
|
+
holds: ElectiveHoldStatusSource[],
|
|
880
|
+
fallbackLocationUuid: string,
|
|
881
|
+
): Promise<Record<number, string>> {
|
|
882
|
+
const statusMap: Record<number, string> = {};
|
|
883
|
+
if (!holds.length || !fallbackLocationUuid?.trim()) {
|
|
884
|
+
return statusMap;
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
// One preview per unique consent token, then match interventions locally.
|
|
888
|
+
const tokenLocations = new Map<string, string>();
|
|
889
|
+
for (const hold of holds) {
|
|
890
|
+
const token = String(hold.consentToken ?? '').trim();
|
|
891
|
+
if (!token || tokenLocations.has(token)) continue;
|
|
892
|
+
tokenLocations.set(token, String(hold.locationUuid ?? '').trim() || fallbackLocationUuid);
|
|
893
|
+
}
|
|
894
|
+
if (!tokenLocations.size) {
|
|
895
|
+
return statusMap;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
const previewByToken = new Map<string, unknown>();
|
|
899
|
+
await Promise.all(
|
|
900
|
+
[...tokenLocations.entries()].map(async ([token, loc]) => {
|
|
901
|
+
try {
|
|
902
|
+
previewByToken.set(token, await getPreauthPreview(token, loc));
|
|
903
|
+
} catch {
|
|
904
|
+
previewByToken.set(token, null);
|
|
905
|
+
}
|
|
906
|
+
}),
|
|
907
|
+
);
|
|
908
|
+
|
|
909
|
+
await Promise.all(
|
|
910
|
+
holds.map(async (hold) => {
|
|
911
|
+
if (hold.id == null) return;
|
|
912
|
+
const token = String(hold.consentToken ?? '').trim();
|
|
913
|
+
if (!token) return;
|
|
914
|
+
|
|
915
|
+
const preview = previewByToken.get(token);
|
|
916
|
+
if (!preview) return;
|
|
917
|
+
|
|
918
|
+
// Intervention-specific status only — never visit-wide overallPreauthFinalised.
|
|
919
|
+
const hieStatus = extractPreauthStatusForIntervention(preview, hold.interventionCode);
|
|
920
|
+
if (!hieStatus) {
|
|
921
|
+
// Token exists but this intervention is not on the preview — do not keep a
|
|
922
|
+
// stale FINALISED/ACTIVE from an earlier bad sync.
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
statusMap[hold.id] = hieStatus;
|
|
927
|
+
|
|
928
|
+
const holdStatus = String(hold.status ?? '')
|
|
929
|
+
.trim()
|
|
930
|
+
.toUpperCase();
|
|
931
|
+
const normalizedHie = hieStatus.trim().toUpperCase();
|
|
932
|
+
if (normalizedHie && normalizedHie !== holdStatus) {
|
|
933
|
+
try {
|
|
934
|
+
await patchPreAuthRequest(hold.id, { status: hieStatus });
|
|
935
|
+
} catch {
|
|
936
|
+
// non-blocking — UI still shows live HIE status via statusMap
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}),
|
|
940
|
+
);
|
|
941
|
+
|
|
942
|
+
return statusMap;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
export type ElectiveHoldRow = PreAuthRequestRecord & {
|
|
946
|
+
patientName: string;
|
|
947
|
+
crNo: string;
|
|
948
|
+
providerDisplay: string;
|
|
949
|
+
providerUuid: string;
|
|
950
|
+
providerNationalId: string;
|
|
951
|
+
encounterDatetime: string;
|
|
952
|
+
clinicalIndications: string;
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
function patientDisplayName(patient: Record<string, unknown> | null | undefined): string {
|
|
956
|
+
if (!patient) return '';
|
|
957
|
+
const display = String(patient.display ?? '').trim();
|
|
958
|
+
if (display) {
|
|
959
|
+
// OpenMRS often returns "Name - identifier"
|
|
960
|
+
return display.split(' - ')[0]?.trim() || display;
|
|
961
|
+
}
|
|
962
|
+
const person = patient.person as { display?: string } | undefined;
|
|
963
|
+
return String(person?.display ?? '').trim();
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
function identifierOfType(
|
|
967
|
+
patient: Record<string, unknown> | null | undefined,
|
|
968
|
+
typeUuid: string,
|
|
969
|
+
): string {
|
|
970
|
+
const ids = (patient?.identifiers ?? []) as Array<{
|
|
971
|
+
identifier?: string;
|
|
972
|
+
identifierType?: { uuid?: string };
|
|
973
|
+
}>;
|
|
974
|
+
const hit = ids.find((i) => i.identifierType?.uuid === typeUuid);
|
|
975
|
+
return String(hit?.identifier ?? '').trim();
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
function providerNationalIdFromAttrs(
|
|
979
|
+
attributes?: Array<{ value?: string; voided?: boolean; attributeType?: { uuid?: string } }>,
|
|
980
|
+
): string {
|
|
981
|
+
const hit = (attributes ?? []).find(
|
|
982
|
+
(a) =>
|
|
983
|
+
!a.voided &&
|
|
984
|
+
a.attributeType?.uuid === IdentifierTypesUuids.PROVIDER_NATIONAL_ID_UUID &&
|
|
985
|
+
a.value,
|
|
986
|
+
);
|
|
987
|
+
return hit?.value ? String(hit.value).trim() : '';
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
async function fetchPatientSummary(patientUuid: string): Promise<{
|
|
991
|
+
name: string;
|
|
992
|
+
crNo: string;
|
|
993
|
+
}> {
|
|
994
|
+
try {
|
|
995
|
+
const res = await openmrsFetch(
|
|
996
|
+
`${restBaseUrl}/patient/${patientUuid}?v=custom:(uuid,display,person:(display),identifiers:(identifier,identifierType:(uuid)))`,
|
|
997
|
+
);
|
|
998
|
+
const patient = res?.data as Record<string, unknown> | undefined;
|
|
999
|
+
return {
|
|
1000
|
+
name: patientDisplayName(patient),
|
|
1001
|
+
crNo: identifierOfType(patient, IdentifierTypesUuids.CLIENT_REGISTRY_NO_UUID),
|
|
1002
|
+
};
|
|
1003
|
+
} catch {
|
|
1004
|
+
return { name: '', crNo: '' };
|
|
1005
|
+
}
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
async function fetchEncounterSummary(encounterUuid: string): Promise<{
|
|
1009
|
+
encounterDatetime: string;
|
|
1010
|
+
providerDisplay: string;
|
|
1011
|
+
providerUuid: string;
|
|
1012
|
+
providerNationalId: string;
|
|
1013
|
+
clinicalIndications: string;
|
|
1014
|
+
}> {
|
|
1015
|
+
const empty = {
|
|
1016
|
+
encounterDatetime: '',
|
|
1017
|
+
providerDisplay: '',
|
|
1018
|
+
providerUuid: '',
|
|
1019
|
+
providerNationalId: '',
|
|
1020
|
+
clinicalIndications: '',
|
|
1021
|
+
};
|
|
1022
|
+
if (!encounterUuid) return empty;
|
|
1023
|
+
try {
|
|
1024
|
+
const res = await openmrsFetch(
|
|
1025
|
+
`${restBaseUrl}/encounter/${encounterUuid}?v=custom:(uuid,encounterDatetime,encounterProviders:(display,provider:(uuid,display,attributes:(value,voided,attributeType:(uuid)))),obs:(uuid,concept:(uuid),value,valueText))`,
|
|
1026
|
+
);
|
|
1027
|
+
const enc = res?.data as Record<string, unknown> | undefined;
|
|
1028
|
+
if (!enc) return empty;
|
|
1029
|
+
|
|
1030
|
+
const providers = (Array.isArray(enc.encounterProviders) ? enc.encounterProviders : []) as Array<{
|
|
1031
|
+
display?: string;
|
|
1032
|
+
provider?: {
|
|
1033
|
+
uuid?: string;
|
|
1034
|
+
display?: string;
|
|
1035
|
+
attributes?: Array<{ value?: string; voided?: boolean; attributeType?: { uuid?: string } }>;
|
|
1036
|
+
};
|
|
1037
|
+
}>;
|
|
1038
|
+
const primary = providers[0];
|
|
1039
|
+
const provider = primary?.provider;
|
|
1040
|
+
const providerDisplay =
|
|
1041
|
+
String(provider?.display ?? '').trim() ||
|
|
1042
|
+
String(primary?.display ?? '')
|
|
1043
|
+
.replace(/\s*:\s*.*$/, '')
|
|
1044
|
+
.trim();
|
|
1045
|
+
const providerUuid = String(provider?.uuid ?? '').trim();
|
|
1046
|
+
const providerNationalId = providerNationalIdFromAttrs(provider?.attributes);
|
|
1047
|
+
|
|
1048
|
+
const obsList = (Array.isArray(enc.obs) ? enc.obs : []) as Record<string, unknown>[];
|
|
1049
|
+
let clinicalIndications = '';
|
|
1050
|
+
for (const o of obsList) {
|
|
1051
|
+
const cu = conceptUuid(o);
|
|
1052
|
+
if (cu === PREAUTH_FORM_CONCEPTS.clinicalIndication || cu === CLINICAL_INDICATIONS_CONCEPT_UUID) {
|
|
1053
|
+
clinicalIndications = obsText(o);
|
|
1054
|
+
break;
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
return {
|
|
1059
|
+
encounterDatetime: String(enc.encounterDatetime ?? ''),
|
|
1060
|
+
providerDisplay,
|
|
1061
|
+
providerUuid,
|
|
1062
|
+
providerNationalId,
|
|
1063
|
+
clinicalIndications,
|
|
1064
|
+
};
|
|
1065
|
+
} catch {
|
|
1066
|
+
return empty;
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
|
|
1070
|
+
/** Resolve patient name, CR, and encounter provider for Accounting elective list / Raise. */
|
|
1071
|
+
export async function enrichElectiveHolds(
|
|
1072
|
+
holds: PreAuthRequestRecord[],
|
|
1073
|
+
clientRegistryIdentifierTypeUuid?: string,
|
|
1074
|
+
): Promise<ElectiveHoldRow[]> {
|
|
1075
|
+
const crType = clientRegistryIdentifierTypeUuid || IdentifierTypesUuids.CLIENT_REGISTRY_NO_UUID;
|
|
1076
|
+
|
|
1077
|
+
return Promise.all(
|
|
1078
|
+
holds.map(async (hold) => {
|
|
1079
|
+
const [patient, encounter] = await Promise.all([
|
|
1080
|
+
fetchPatientSummary(hold.patientUuid),
|
|
1081
|
+
fetchEncounterSummary(hold.encounterUuid ?? ''),
|
|
1082
|
+
]);
|
|
1083
|
+
// Prefer configured CR type when it differs from default
|
|
1084
|
+
let crNo = patient.crNo;
|
|
1085
|
+
if (crType !== IdentifierTypesUuids.CLIENT_REGISTRY_NO_UUID && hold.patientUuid) {
|
|
1086
|
+
try {
|
|
1087
|
+
crNo = (await fetchPatientCrNumber(hold.patientUuid, crType)) || crNo;
|
|
1088
|
+
} catch {
|
|
1089
|
+
// keep patient.crNo
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
return {
|
|
1093
|
+
...hold,
|
|
1094
|
+
patientName: patient.name || hold.patientUuid,
|
|
1095
|
+
crNo,
|
|
1096
|
+
providerDisplay: encounter.providerDisplay,
|
|
1097
|
+
providerUuid: encounter.providerUuid,
|
|
1098
|
+
providerNationalId: encounter.providerNationalId,
|
|
1099
|
+
encounterDatetime: encounter.encounterDatetime,
|
|
1100
|
+
clinicalIndications: encounter.clinicalIndications,
|
|
1101
|
+
};
|
|
1102
|
+
}),
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
export type PreauthEncounterCard = {
|
|
1107
|
+
uuid: string;
|
|
1108
|
+
encounterDatetime: string;
|
|
1109
|
+
clinicalIndications: string;
|
|
1110
|
+
expectedServiceStartDate: string;
|
|
1111
|
+
locationDisplay: string;
|
|
1112
|
+
hold?: PreAuthRequestRecord | null;
|
|
1113
|
+
/** Planned service concept UUID when encoded on the hold orderNo */
|
|
1114
|
+
plannedServiceConceptUuid: string;
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
function obsText(obs: Record<string, unknown> | undefined): string {
|
|
1118
|
+
if (!obs) return '';
|
|
1119
|
+
if (typeof obs.valueText === 'string' && obs.valueText.trim()) return obs.valueText.trim();
|
|
1120
|
+
if (typeof obs.value === 'string' && obs.value.trim()) return obs.value.trim();
|
|
1121
|
+
if (obs.value && typeof obs.value === 'object' && 'display' in (obs.value as object)) {
|
|
1122
|
+
return String((obs.value as { display?: string }).display ?? '').trim();
|
|
1123
|
+
}
|
|
1124
|
+
return '';
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
function obsDate(obs: Record<string, unknown> | undefined): string {
|
|
1128
|
+
if (!obs) return '';
|
|
1129
|
+
const raw =
|
|
1130
|
+
(typeof obs.valueDate === 'string' && obs.valueDate) ||
|
|
1131
|
+
(typeof obs.valueDatetime === 'string' && obs.valueDatetime) ||
|
|
1132
|
+
(typeof obs.value === 'string' && obs.value) ||
|
|
1133
|
+
'';
|
|
1134
|
+
const d = dayjs(raw);
|
|
1135
|
+
return d.isValid() ? d.format('YYYY-MM-DD') : '';
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
function conceptUuid(obs: Record<string, unknown>): string {
|
|
1139
|
+
const c = obs.concept;
|
|
1140
|
+
if (c && typeof c === 'object' && 'uuid' in (c as object)) {
|
|
1141
|
+
return String((c as { uuid?: string }).uuid ?? '');
|
|
1142
|
+
}
|
|
1143
|
+
return typeof c === 'string' ? c : '';
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/** List PREAUTHORIZATION encounters for the patient chart elective page. */
|
|
1147
|
+
export async function fetchPreauthEncounterCards(
|
|
1148
|
+
patientUuid: string,
|
|
1149
|
+
encounterTypeUuid?: string,
|
|
1150
|
+
locationUuid?: string,
|
|
1151
|
+
): Promise<PreauthEncounterCard[]> {
|
|
1152
|
+
if (!patientUuid) return [];
|
|
1153
|
+
const typeUuid = encounterTypeUuid || PREAUTH_ENCOUNTER_TYPE_UUID;
|
|
1154
|
+
try {
|
|
1155
|
+
const qs = new URLSearchParams({
|
|
1156
|
+
patient: patientUuid,
|
|
1157
|
+
encounterType: typeUuid,
|
|
1158
|
+
v: 'custom:(uuid,encounterDatetime,location:(display),obs:(uuid,concept:(uuid),value,valueText,valueDate,valueDatetime))',
|
|
1159
|
+
limit: '50',
|
|
1160
|
+
});
|
|
1161
|
+
const res = await openmrsFetch(`${restBaseUrl}/encounter?${qs.toString()}`);
|
|
1162
|
+
const results = (res?.data?.results ?? []) as Array<Record<string, unknown>>;
|
|
1163
|
+
|
|
1164
|
+
// Chart view: load holds by patient only so a session location mismatch does not
|
|
1165
|
+
// hide ACTIVE / raised rows (location filter still applies to Accounting lists).
|
|
1166
|
+
let holds: PreAuthRequestRecord[] = [];
|
|
1167
|
+
try {
|
|
1168
|
+
holds = await fetchElectiveHolds({ patientUuid });
|
|
1169
|
+
} catch {
|
|
1170
|
+
holds = [];
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
const holdByEncounter = new Map<string, PreAuthRequestRecord>();
|
|
1174
|
+
for (const h of holds) {
|
|
1175
|
+
const encUuid = String(h.encounterUuid ?? '').trim();
|
|
1176
|
+
if (encUuid) {
|
|
1177
|
+
holdByEncounter.set(encUuid, h);
|
|
1178
|
+
continue;
|
|
1179
|
+
}
|
|
1180
|
+
// Fallback: ELECTIVE-{encounterUuid} or ELECTIVE-{encounterUuid}::{conceptUuid}
|
|
1181
|
+
const orderNo = String(h.orderNo ?? '').trim();
|
|
1182
|
+
const m = orderNo.match(/^ELECTIVE-([0-9a-f-]{36})(?:::|$)/i);
|
|
1183
|
+
if (m?.[1]) {
|
|
1184
|
+
holdByEncounter.set(m[1], h);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
const cards: PreauthEncounterCard[] = results.map((enc) => {
|
|
1189
|
+
const uuid = String(enc.uuid ?? '');
|
|
1190
|
+
const obsList = (Array.isArray(enc.obs) ? enc.obs : []) as Record<string, unknown>[];
|
|
1191
|
+
const byConcept = new Map<string, Record<string, unknown>>();
|
|
1192
|
+
for (const o of obsList) {
|
|
1193
|
+
const cu = conceptUuid(o);
|
|
1194
|
+
if (cu) byConcept.set(cu, o);
|
|
1195
|
+
}
|
|
1196
|
+
const clinical = obsText(byConcept.get(PREAUTH_FORM_CONCEPTS.clinicalIndication));
|
|
1197
|
+
const expected = obsDate(byConcept.get(PREAUTH_FORM_CONCEPTS.expectedServiceStartDate || PREAUTH_FORM_CONCEPTS.startDate));
|
|
1198
|
+
const loc = enc.location as { display?: string } | undefined;
|
|
1199
|
+
const hold = holdByEncounter.get(uuid) ?? null;
|
|
1200
|
+
const plannedFromObs = (() => {
|
|
1201
|
+
const configured = plannedServiceObsConcept();
|
|
1202
|
+
if (configured) {
|
|
1203
|
+
const t = obsText(byConcept.get(configured));
|
|
1204
|
+
if (t) return t;
|
|
1205
|
+
}
|
|
1206
|
+
return (
|
|
1207
|
+
obsText(byConcept.get(PREAUTH_FORM_CONCEPTS.plannedServiceConcept)) || ''
|
|
1208
|
+
);
|
|
1209
|
+
})();
|
|
1210
|
+
return {
|
|
1211
|
+
uuid,
|
|
1212
|
+
encounterDatetime: String(enc.encounterDatetime ?? ''),
|
|
1213
|
+
clinicalIndications: clinical,
|
|
1214
|
+
expectedServiceStartDate: expected,
|
|
1215
|
+
locationDisplay: String(loc?.display ?? ''),
|
|
1216
|
+
hold,
|
|
1217
|
+
plannedServiceConceptUuid:
|
|
1218
|
+
plannedFromObs || plannedConceptUuidFromOrderNo(hold?.orderNo),
|
|
1219
|
+
};
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1222
|
+
// Also surface holds whose encounter is missing from the OpenMRS list (wrong encounter
|
|
1223
|
+
// type config, etc.) so ACTIVE preauths are not invisible.
|
|
1224
|
+
const seenEncounters = new Set(cards.map((c) => c.uuid));
|
|
1225
|
+
for (const h of holds) {
|
|
1226
|
+
const encUuid = String(h.encounterUuid ?? '').trim();
|
|
1227
|
+
const fromOrder = String(h.orderNo ?? '').match(/^ELECTIVE-([0-9a-f-]{36})(?:::|$)/i)?.[1];
|
|
1228
|
+
const key = encUuid || fromOrder || '';
|
|
1229
|
+
if (!key || seenEncounters.has(key)) continue;
|
|
1230
|
+
seenEncounters.add(key);
|
|
1231
|
+
cards.push({
|
|
1232
|
+
uuid: key,
|
|
1233
|
+
encounterDatetime: h.dateCreated || '',
|
|
1234
|
+
clinicalIndications: '',
|
|
1235
|
+
expectedServiceStartDate: h.expectedServiceStartDate
|
|
1236
|
+
? dayjs(h.expectedServiceStartDate).format('YYYY-MM-DD')
|
|
1237
|
+
: '',
|
|
1238
|
+
locationDisplay: '',
|
|
1239
|
+
hold: h,
|
|
1240
|
+
plannedServiceConceptUuid: plannedConceptUuidFromOrderNo(h.orderNo),
|
|
1241
|
+
});
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
return cards.sort((a, b) => {
|
|
1245
|
+
const ta = dayjs(a.encounterDatetime).valueOf() || 0;
|
|
1246
|
+
const tb = dayjs(b.encounterDatetime).valueOf() || 0;
|
|
1247
|
+
return tb - ta;
|
|
1248
|
+
});
|
|
1249
|
+
} catch {
|
|
1250
|
+
return [];
|
|
1251
|
+
}
|
|
1252
|
+
}
|
|
1253
|
+
|
|
1254
|
+
/** REST order subclass for POST /encounter orders (must match OrderType.javaClassName). */
|
|
1255
|
+
export type RestOrderType = 'order' | 'testorder' | 'drugorder';
|
|
1256
|
+
|
|
1257
|
+
function restTypeFromJavaClassName(javaClassName: string | null | undefined): RestOrderType | null {
|
|
1258
|
+
const name = String(javaClassName ?? '').trim();
|
|
1259
|
+
if (!name) return null;
|
|
1260
|
+
if (name.endsWith('TestOrder') || name === 'org.openmrs.TestOrder') return 'testorder';
|
|
1261
|
+
if (name.endsWith('DrugOrder') || name === 'org.openmrs.DrugOrder') return 'drugorder';
|
|
1262
|
+
if (name.endsWith('.Order') || name === 'org.openmrs.Order') return 'order';
|
|
1263
|
+
return null;
|
|
1264
|
+
}
|
|
1265
|
+
|
|
1266
|
+
function restTypeFromConceptClassName(className: string | null | undefined): RestOrderType {
|
|
1267
|
+
const n = String(className ?? '')
|
|
1268
|
+
.trim()
|
|
1269
|
+
.toLowerCase();
|
|
1270
|
+
if (!n) return 'order';
|
|
1271
|
+
if (n.includes('drug')) return 'drugorder';
|
|
1272
|
+
// LabTest, Test, LabSet, etc. map to TestOrder via order_type_class_map in most AMRS installs.
|
|
1273
|
+
if (n.includes('test') || n.includes('lab')) return 'testorder';
|
|
1274
|
+
return 'order';
|
|
1275
|
+
}
|
|
1276
|
+
|
|
1277
|
+
/**
|
|
1278
|
+
* Resolve the REST `type` for an orderable concept so OpenMRS does not reject
|
|
1279
|
+
* the payload (e.g. TestOrder order type vs plain Order instance).
|
|
1280
|
+
*/
|
|
1281
|
+
export async function resolveRestOrderTypeForConcept(conceptUuid: string): Promise<RestOrderType> {
|
|
1282
|
+
const uuid = (conceptUuid ?? '').trim();
|
|
1283
|
+
if (!uuid) return 'order';
|
|
1284
|
+
|
|
1285
|
+
let conceptClassUuid = '';
|
|
1286
|
+
let conceptClassName = '';
|
|
1287
|
+
try {
|
|
1288
|
+
const conceptRes = await openmrsFetch(
|
|
1289
|
+
`${restBaseUrl}/concept/${uuid}?v=custom:(uuid,conceptClass:(uuid,display,name))`,
|
|
1290
|
+
);
|
|
1291
|
+
const cc = conceptRes?.data?.conceptClass as
|
|
1292
|
+
| { uuid?: string; display?: string; name?: string }
|
|
1293
|
+
| undefined;
|
|
1294
|
+
conceptClassUuid = String(cc?.uuid ?? '').trim();
|
|
1295
|
+
conceptClassName = String(cc?.display ?? cc?.name ?? '').trim();
|
|
1296
|
+
} catch {
|
|
1297
|
+
return 'order';
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
try {
|
|
1301
|
+
const otRes = await openmrsFetch(
|
|
1302
|
+
`${restBaseUrl}/ordertype?v=custom:(uuid,display,javaClassName,conceptClasses:(uuid,display))&limit=100`,
|
|
1303
|
+
);
|
|
1304
|
+
const types = (otRes?.data?.results ?? []) as Array<{
|
|
1305
|
+
javaClassName?: string;
|
|
1306
|
+
conceptClasses?: Array<{ uuid?: string; display?: string }>;
|
|
1307
|
+
}>;
|
|
1308
|
+
|
|
1309
|
+
if (conceptClassUuid) {
|
|
1310
|
+
const matched = types.find((t) =>
|
|
1311
|
+
(t.conceptClasses ?? []).some((c) => c?.uuid === conceptClassUuid),
|
|
1312
|
+
);
|
|
1313
|
+
const fromMap = restTypeFromJavaClassName(matched?.javaClassName);
|
|
1314
|
+
if (fromMap) return fromMap;
|
|
1315
|
+
}
|
|
1316
|
+
} catch {
|
|
1317
|
+
// fall through to class-name heuristic
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
return restTypeFromConceptClassName(conceptClassName);
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1323
|
+
/** Create an OpenMRS order for an ACTIVE/FINALISED elective preauth using the planned service concept. */
|
|
1324
|
+
export async function createElectiveServiceOrder(opts: {
|
|
1325
|
+
patientUuid: string;
|
|
1326
|
+
visitUuid: string;
|
|
1327
|
+
locationUuid: string;
|
|
1328
|
+
providerUuid: string;
|
|
1329
|
+
conceptUuid: string;
|
|
1330
|
+
orderEncounterTypeUuid: string;
|
|
1331
|
+
outPatientCareSettingUuid: string;
|
|
1332
|
+
}): Promise<{ orderUuid: string; orderNumber: string }> {
|
|
1333
|
+
const conceptUuid = (opts.conceptUuid ?? '').trim();
|
|
1334
|
+
if (!conceptUuid) {
|
|
1335
|
+
throw new Error('Missing planned service concept for order');
|
|
1336
|
+
}
|
|
1337
|
+
if (!opts.providerUuid?.trim()) {
|
|
1338
|
+
throw new Error('A provider is required to create the order');
|
|
1339
|
+
}
|
|
1340
|
+
if (!opts.orderEncounterTypeUuid?.trim() || !opts.outPatientCareSettingUuid?.trim()) {
|
|
1341
|
+
throw new Error('Order encounter type and outpatient care setting must be configured');
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
const orderRestType = await resolveRestOrderTypeForConcept(conceptUuid);
|
|
1345
|
+
|
|
1346
|
+
const dto: CreateOrderEncounterDto = {
|
|
1347
|
+
patient: opts.patientUuid,
|
|
1348
|
+
location: opts.locationUuid,
|
|
1349
|
+
encounterType: opts.orderEncounterTypeUuid,
|
|
1350
|
+
encounterDatetime: new Date().toISOString(),
|
|
1351
|
+
visit: opts.visitUuid,
|
|
1352
|
+
obs: [],
|
|
1353
|
+
orders: [
|
|
1354
|
+
{
|
|
1355
|
+
action: 'NEW',
|
|
1356
|
+
type: orderRestType,
|
|
1357
|
+
patient: opts.patientUuid,
|
|
1358
|
+
careSetting: opts.outPatientCareSettingUuid,
|
|
1359
|
+
orderer: opts.providerUuid,
|
|
1360
|
+
concept: conceptUuid,
|
|
1361
|
+
urgency: 'ROUTINE',
|
|
1362
|
+
},
|
|
1363
|
+
],
|
|
1364
|
+
};
|
|
1365
|
+
|
|
1366
|
+
const encounter = await createOrderEncounter(dto);
|
|
1367
|
+
const createdOrder = encounter?.orders?.[0];
|
|
1368
|
+
if (!createdOrder?.uuid) {
|
|
1369
|
+
throw new Error('Order encounter was created without an order');
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
const order = await getOrder(createdOrder.uuid);
|
|
1373
|
+
const orderNumber = String(order?.orderNumber ?? '').trim();
|
|
1374
|
+
if (!orderNumber) {
|
|
1375
|
+
throw new Error('Order was created but order number is missing');
|
|
1376
|
+
}
|
|
1377
|
+
return { orderUuid: createdOrder.uuid, orderNumber };
|
|
1378
|
+
}
|