@kenyaemr/esm-billing-app 5.4.2-pre.2676 → 5.4.2-pre.2682
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/.turbo/turbo-build.log +4 -4
- package/dist/127.js +1 -1
- package/dist/270.js +1 -1
- package/dist/270.js.map +1 -1
- package/dist/40.js +1 -1
- package/dist/916.js +1 -1
- package/dist/kenyaemr-esm-billing-app.js.buildmanifest.json +15 -15
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/benefits-package/forms/packages-and-interventions-form.component.tsx +53 -41
- package/src/hooks/useInterventions.ts +29 -152
- package/src/hooks/usePackages.ts +27 -14
- package/translations/am.json +1 -1
- package/translations/en.json +1 -1
- package/translations/sw.json +1 -1
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"},{"component":"requirePaymentModal","routeRegex":"^patient/.+/chart","online":true,"offline":false},{"component":"billingAdmin","route":"billing-admin"}],"extensions":[{"component":"accountingDashboardLink","name":"accounting-dashboard-link","slots":["homepage-dashboard-slot"],"meta":{"name":"accounting","slot":"accounting-dashboard-slot","title":"Accounting"}},{"name":"billing-dashboard","component":"billingDashboard","slot":"accounting-dashboard-slot"},{"component":"benefitsPackageDashboardLink","name":"benefits-package-dashboard-link","meta":{"name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot","path":"insurance-benefits","columns":1,"columnSpan":1},"featureFlag":"healthInformationExchange"},{"component":"benefitsPackage","name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot"},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"component":"benefitsEligibilyRequestForm","name":"benefits-eligibility-request-form"},{"component":"benefitsPreAuthForm","name":"benefits-pre-auth-form"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"Billing","layoutMode":"anchored"}},{"name":"billing-check-in-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"initiate-payment-modal","component":"initiatePaymentDialog"},{"name":"delete-billableservice-modal","component":"deleteBillableServiceModal"},{"name":"refund-bill-modal","component":"refundBillModal"},{"name":"delete-bill-modal","component":"deleteBillModal"},{"name":"lab-order-billable-item","component":"labOrder","slot":"top-of-lab-order-form-slot"},{"name":"procedure-order-billable-item","component":"procedureOrder","slot":"top-of-procedure-order-form-slot"},{"name":"imaging-order-billable-item","component":"imagingOrder","slot":"top-of-imaging-order-form-slot"},{"name":"price-info-order","component":"priceInfoOrder"},{"name":"drug-order-billable-item","component":"drugOrder","slot":"medication-info-slot"},{"name":"order-action-button","component":"orderActionButton","slots":["prescription-action-button-slot","imaging-orders-action","procedure-orders-action","tests-ordered-actions-slot"],"order":0},{"component":"claimsManagementOverviewDashboardLink","name":"claims-management-overview-link","slots":["claims-management-dashboard-link-slot"]},{"component":"preAuthRequestsDashboardLink","name":"preauthrequest-overview-link","slots":["claims-management-dashboard-link-slot"]},{"component":"claimsOverview","name":"claims-overview-dashboard-link","slot":"claims-management-overview-slot"},{"component":"waiveBillActionButton","name":"waive-bill-action-button","slot":"bill-actions-slot"},{"component":"deleteBillActionButton","name":"delete-bill-action-button","slot":"bill-actions-slot"},{"component":"refundLineItem","name":"refund-line-item","slot":"bill-actions-overflow-menu-slot"},{"name":"edit-line-item","component":"editLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"cancel-line-item","component":"cancelLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"patient-info-sha-status","component":"patientBannerShaStatus","slot":"patient-banner-tags-slot"},{"name":"payments-points-dashboard-link","component":"paymentPointDashboardLink","slot":"billing-admin-dashboard-slot","meta":{"name":"cashier-points","title":"Payment Point","slot":"payment-point-dashboard-slot"}},{"name":"payment-points-dashboard","component":"paymentPoints","slot":"payment-point-dashboard-slot"},{"name":"payment-mode-dashboard-link","component":"paymentModeLink","slot":"billing-admin-dashboard-slot","meta":{"name":"payment-modes","title":"Payment Mode","slot":"payment-mode-dashboard-slot"}},{"name":"payment-mode-dashboard","component":"paymentModeDashboard","slot":"payment-mode-dashboard-slot"},{"name":"bill-deposit-dashboard-link","component":"billDepositDashboardLink","slot":"billing-admin-dashboard-slot","meta":{"name":"bill-deposit","title":"Bill Deposit","slot":"billing-deposit-dashboard-slot"}},{"name":"bill-deposit-dashboard","component":"billDepositDashboard","slot":"billing-deposit-dashboard-slot"},{"name":"billable-exemptions-dashboard-link","component":"billableExemptionsLink","slot":"billing-admin-dashboard-slot","meta":{"name":"billable-exemptions","title":"Billable Exemptions","slot":"billing-exemptions-dashboard-slot"}},{"name":"billable-exemptions-dashboard","component":"billableExemptions","slot":"billing-exemptions-dashboard-slot"},{"name":"clinical-charges-dashboard-link","component":"clinicalChargesLink","slot":"billing-admin-dashboard-slot","meta":{"name":"clinical-charges","title":"Clinical Charges","slot":"clinical-charges-dashboard-slot"}},{"name":"clinical-charges-dashboard","component":"clinicalCharges","slot":"clinical-charges-dashboard-slot"},{"name":"payment-history-dashboard-link","component":"paymentHistoryLink","slot":"billing-admin-dashboard-slot","meta":{"name":"payment-history","title":"Payment History","slot":"payment-history-dashboard-slot"}},{"name":"payment-history-dashboard","component":"paymentHistoryDashboard","slot":"payment-history-dashboard-slot"},{"name":"patient-billing-dashboard-link","component":"patientBillingLink","slot":"billing-admin-dashboard-slot","meta":{"name":"patient-billing","title":"Patient Billing","slot":"patient-billing-dashboard-slot"}},{"name":"patient-billing-dashboard","component":"patientBilling","slot":"patient-billing-dashboard-slot"}],"workspaces":[{"name":"create-bill-workspace","component":"createBillWorkspace","title":"Create Bill Workspace","type":"other-form"},{"name":"waive-bill-form","component":"waiveBillForm","title":"Waive Bill Form","type":"other-form"},{"name":"edit-bill-form","component":"editBillForm","title":"Edit Bill Form","type":"other-form"},{"name":"billable-service-form","component":"addServiceForm","title":"Create Charge Item Form","type":"other-form"},{"name":"commodity-form","component":"addCommodityForm","title":"Create Charge Item Form","type":"other-form"},{"name":"billing-form","component":"billingForm","title":"Billing Form","type":"other-form","width":"extra-wide"},{"name":"payment-mode-workspace","component":"paymentModeWorkspace","title":"Payment Mode Workspace","type":"other-form"},{"name":"cancel-bill-workspace","component":"cancelBillWorkspace","title":"Cancel Bill Workspace","type":"other-form"},{"name":"add-deposit-workspace","component":"addDepositWorkspace","title":"Add Deposit","type":"other-form"},{"name":"deposit-transaction-workspace","component":"depositTransactionWorkspace","title":"Deposit Transaction","type":"other-form"},{"name":"payment-workspace","component":"paymentWorkspace","title":"Payment Workspace","type":"other-form"}],"modals":[{"name":"create-payment-point","component":"createPaymentPoint"},{"name":"clock-out-modal","component":"clockOut"},{"name":"bulk-import-billable-services-modal","component":"bulkImportBillableServicesModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"manage-claim-request-modal","component":"manageClaimRequestModal"},{"name":"clock-in-modal","component":"clockIn"},{"name":"create-bill-item-modal","component":"createBillItemModal"},{"name":"delete-deposit-modal","component":"deleteDepositModal"},{"name":"reverse-transaction-modal","component":"reverseTransactionModal"},{"name":"print-preview-modal","component":"printPreviewModal"},{"name":"bill-action-modal","component":"billActionModal"},{"name":"require-billing-modal","component":"requirePaymentModal"}],"version":"5.4.2-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemr":"^19.0.0"},"pages":[{"component":"billableServicesHome","route":"billable-services"},{"component":"requirePaymentModal","routeRegex":"^patient/.+/chart","online":true,"offline":false},{"component":"billingAdmin","route":"billing-admin"}],"extensions":[{"component":"accountingDashboardLink","name":"accounting-dashboard-link","slots":["homepage-dashboard-slot"],"meta":{"name":"accounting","slot":"accounting-dashboard-slot","title":"Accounting"}},{"name":"billing-dashboard","component":"billingDashboard","slot":"accounting-dashboard-slot"},{"component":"benefitsPackageDashboardLink","name":"benefits-package-dashboard-link","meta":{"name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot","path":"insurance-benefits","columns":1,"columnSpan":1},"featureFlag":"healthInformationExchange"},{"component":"benefitsPackage","name":"benefits-package","slot":"patient-chart-benefits-dashboard-slot"},{"component":"root","name":"billing-dashboard-root","slot":"billing-dashboard-slot"},{"component":"benefitsEligibilyRequestForm","name":"benefits-eligibility-request-form"},{"component":"benefitsPreAuthForm","name":"benefits-pre-auth-form"},{"name":"billing-patient-summary","component":"billingPatientSummary","slot":"patient-chart-billing-dashboard-slot","order":10,"meta":{"columnSpan":4}},{"name":"billing-summary-dashboard-link","component":"billingSummaryDashboardLink","order":11,"meta":{"columns":1,"columnSpan":1,"slot":"patient-chart-billing-dashboard-slot","path":"Billing","layoutMode":"anchored"}},{"name":"billing-check-in-form","slot":"extra-visit-attribute-slot","component":"billingCheckInForm"},{"name":"patient-banner-billing-tags","component":"visitAttributeTags","slot":"patient-banner-tags-slot","order":2},{"name":"initiate-payment-modal","component":"initiatePaymentDialog"},{"name":"delete-billableservice-modal","component":"deleteBillableServiceModal"},{"name":"refund-bill-modal","component":"refundBillModal"},{"name":"delete-bill-modal","component":"deleteBillModal"},{"name":"lab-order-billable-item","component":"labOrder","slot":"top-of-lab-order-form-slot"},{"name":"procedure-order-billable-item","component":"procedureOrder","slot":"top-of-procedure-order-form-slot"},{"name":"imaging-order-billable-item","component":"imagingOrder","slot":"top-of-imaging-order-form-slot"},{"name":"price-info-order","component":"priceInfoOrder"},{"name":"drug-order-billable-item","component":"drugOrder","slot":"medication-info-slot"},{"name":"order-action-button","component":"orderActionButton","slots":["prescription-action-button-slot","imaging-orders-action","procedure-orders-action","tests-ordered-actions-slot"],"order":0},{"component":"claimsManagementOverviewDashboardLink","name":"claims-management-overview-link","slots":["claims-management-dashboard-link-slot"]},{"component":"preAuthRequestsDashboardLink","name":"preauthrequest-overview-link","slots":["claims-management-dashboard-link-slot"]},{"component":"claimsOverview","name":"claims-overview-dashboard-link","slot":"claims-management-overview-slot"},{"component":"waiveBillActionButton","name":"waive-bill-action-button","slot":"bill-actions-slot"},{"component":"deleteBillActionButton","name":"delete-bill-action-button","slot":"bill-actions-slot"},{"component":"refundLineItem","name":"refund-line-item","slot":"bill-actions-overflow-menu-slot"},{"name":"edit-line-item","component":"editLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"cancel-line-item","component":"cancelLineItem","slot":"bill-actions-overflow-menu-slot"},{"name":"patient-info-sha-status","component":"patientBannerShaStatus","slot":"patient-banner-tags-slot"},{"name":"payments-points-dashboard-link","component":"paymentPointDashboardLink","slot":"billing-admin-dashboard-slot","meta":{"name":"cashier-points","title":"Payment Point","slot":"payment-point-dashboard-slot"}},{"name":"payment-points-dashboard","component":"paymentPoints","slot":"payment-point-dashboard-slot"},{"name":"payment-mode-dashboard-link","component":"paymentModeLink","slot":"billing-admin-dashboard-slot","meta":{"name":"payment-modes","title":"Payment Mode","slot":"payment-mode-dashboard-slot"}},{"name":"payment-mode-dashboard","component":"paymentModeDashboard","slot":"payment-mode-dashboard-slot"},{"name":"bill-deposit-dashboard-link","component":"billDepositDashboardLink","slot":"billing-admin-dashboard-slot","meta":{"name":"bill-deposit","title":"Bill Deposit","slot":"billing-deposit-dashboard-slot"}},{"name":"bill-deposit-dashboard","component":"billDepositDashboard","slot":"billing-deposit-dashboard-slot"},{"name":"billable-exemptions-dashboard-link","component":"billableExemptionsLink","slot":"billing-admin-dashboard-slot","meta":{"name":"billable-exemptions","title":"Billable Exemptions","slot":"billing-exemptions-dashboard-slot"}},{"name":"billable-exemptions-dashboard","component":"billableExemptions","slot":"billing-exemptions-dashboard-slot"},{"name":"clinical-charges-dashboard-link","component":"clinicalChargesLink","slot":"billing-admin-dashboard-slot","meta":{"name":"clinical-charges","title":"Clinical Charges","slot":"clinical-charges-dashboard-slot"}},{"name":"clinical-charges-dashboard","component":"clinicalCharges","slot":"clinical-charges-dashboard-slot"},{"name":"payment-history-dashboard-link","component":"paymentHistoryLink","slot":"billing-admin-dashboard-slot","meta":{"name":"payment-history","title":"Payment History","slot":"payment-history-dashboard-slot"}},{"name":"payment-history-dashboard","component":"paymentHistoryDashboard","slot":"payment-history-dashboard-slot"},{"name":"patient-billing-dashboard-link","component":"patientBillingLink","slot":"billing-admin-dashboard-slot","meta":{"name":"patient-billing","title":"Patient Billing","slot":"patient-billing-dashboard-slot"}},{"name":"patient-billing-dashboard","component":"patientBilling","slot":"patient-billing-dashboard-slot"}],"workspaces":[{"name":"create-bill-workspace","component":"createBillWorkspace","title":"Create Bill Workspace","type":"other-form"},{"name":"waive-bill-form","component":"waiveBillForm","title":"Waive Bill Form","type":"other-form"},{"name":"edit-bill-form","component":"editBillForm","title":"Edit Bill Form","type":"other-form"},{"name":"billable-service-form","component":"addServiceForm","title":"Create Charge Item Form","type":"other-form"},{"name":"commodity-form","component":"addCommodityForm","title":"Create Charge Item Form","type":"other-form"},{"name":"billing-form","component":"billingForm","title":"Billing Form","type":"other-form","width":"extra-wide"},{"name":"payment-mode-workspace","component":"paymentModeWorkspace","title":"Payment Mode Workspace","type":"other-form"},{"name":"cancel-bill-workspace","component":"cancelBillWorkspace","title":"Cancel Bill Workspace","type":"other-form"},{"name":"add-deposit-workspace","component":"addDepositWorkspace","title":"Add Deposit","type":"other-form"},{"name":"deposit-transaction-workspace","component":"depositTransactionWorkspace","title":"Deposit Transaction","type":"other-form"},{"name":"payment-workspace","component":"paymentWorkspace","title":"Payment Workspace","type":"other-form"}],"modals":[{"name":"create-payment-point","component":"createPaymentPoint"},{"name":"clock-out-modal","component":"clockOut"},{"name":"bulk-import-billable-services-modal","component":"bulkImportBillableServicesModal"},{"name":"delete-payment-mode-modal","component":"deletePaymentModeModal"},{"name":"manage-claim-request-modal","component":"manageClaimRequestModal"},{"name":"clock-in-modal","component":"clockIn"},{"name":"create-bill-item-modal","component":"createBillItemModal"},{"name":"delete-deposit-modal","component":"deleteDepositModal"},{"name":"reverse-transaction-modal","component":"reverseTransactionModal"},{"name":"print-preview-modal","component":"printPreviewModal"},{"name":"bill-action-modal","component":"billActionModal"},{"name":"require-billing-modal","component":"requirePaymentModal"}],"version":"5.4.2-pre.2682"}
|
package/package.json
CHANGED
|
@@ -11,39 +11,53 @@ type Props = {
|
|
|
11
11
|
patientUuid: string;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const SHABenefitPackagesAndInterventions: React.FC<Props> = ({ patientUuid }) => {
|
|
15
15
|
const form = useFormContext<{ packages: Array<string>; interventions: Array<string>; policyNumber: string }>();
|
|
16
16
|
const { shaIdentificationNumberUUID } = useConfig<BillingConfig>();
|
|
17
|
-
const { isLoading: packagesLoading, error: packageError, packages } = usePackages();
|
|
18
17
|
const { t } = useTranslation();
|
|
19
18
|
const { error, isLoading, patient } = usePatient(patientUuid);
|
|
19
|
+
|
|
20
|
+
const patientGender = useMemo(() => {
|
|
21
|
+
return patient?.gender === 'male' ? 'male' : 'female';
|
|
22
|
+
}, [patient]);
|
|
23
|
+
|
|
24
|
+
const {
|
|
25
|
+
isLoading: packagesLoading,
|
|
26
|
+
error: packageError,
|
|
27
|
+
packages,
|
|
28
|
+
} = usePackages({
|
|
29
|
+
applicable_gender: patientGender,
|
|
30
|
+
});
|
|
31
|
+
|
|
20
32
|
const selectedPackageObservable = form.watch('packages');
|
|
21
33
|
const shaNumber = useMemo(
|
|
22
34
|
() => patient?.identifier?.find((id) => id?.type?.coding[0]?.code === shaIdentificationNumberUUID)?.value,
|
|
23
35
|
[patient, shaIdentificationNumberUUID],
|
|
24
36
|
);
|
|
37
|
+
|
|
25
38
|
const { setValue } = form;
|
|
39
|
+
|
|
26
40
|
useEffect(() => {
|
|
27
41
|
if (shaNumber) {
|
|
28
42
|
setValue('policyNumber', shaNumber);
|
|
29
43
|
}
|
|
30
44
|
}, [shaNumber, setValue]);
|
|
31
45
|
|
|
32
|
-
if (packagesLoading) {
|
|
46
|
+
if (isLoading || packagesLoading) {
|
|
33
47
|
return (
|
|
34
48
|
<InlineLoading description={t('loading', 'Loading')} iconDescription={t('loading', 'Loading data') + '...'} />
|
|
35
49
|
);
|
|
36
50
|
}
|
|
37
51
|
|
|
38
|
-
if (packageError) {
|
|
52
|
+
if (error || packageError) {
|
|
39
53
|
return (
|
|
40
54
|
<InlineNotification
|
|
41
55
|
aria-label="closes notification"
|
|
42
56
|
kind="error"
|
|
43
57
|
lowContrast={true}
|
|
44
58
|
statusIconDescription="notification"
|
|
45
|
-
title={t('
|
|
46
|
-
subtitle={packageError?.message}
|
|
59
|
+
title={t('errorLoadingData', 'Error loading data')}
|
|
60
|
+
subtitle={packageError?.message ?? error?.message}
|
|
47
61
|
/>
|
|
48
62
|
);
|
|
49
63
|
}
|
|
@@ -54,46 +68,44 @@ const SHABenefitPackangesAndInterventions: React.FC<Props> = ({ patientUuid }) =
|
|
|
54
68
|
<Controller
|
|
55
69
|
control={form.control}
|
|
56
70
|
name="packages"
|
|
57
|
-
render={({ field }) =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
return `${_package.packageCode}-${_package.packageName}`;
|
|
84
|
-
}}
|
|
85
|
-
/>
|
|
86
|
-
)}
|
|
87
|
-
</>
|
|
88
|
-
)}
|
|
71
|
+
render={({ field }) => {
|
|
72
|
+
return (
|
|
73
|
+
<MultiSelect
|
|
74
|
+
ref={field.ref}
|
|
75
|
+
invalid={!!form.formState.errors[field.name]?.message}
|
|
76
|
+
invalidText={form.formState.errors[field.name]?.message}
|
|
77
|
+
id="packages"
|
|
78
|
+
titleText={t('package', 'Packages')}
|
|
79
|
+
onChange={(e) => {
|
|
80
|
+
field.onChange(e.selectedItems);
|
|
81
|
+
}}
|
|
82
|
+
selectedItems={field.value}
|
|
83
|
+
label={t('choosePackage', 'Choose package')}
|
|
84
|
+
items={packages.map((r) => r.uuid)}
|
|
85
|
+
itemToString={(item) => {
|
|
86
|
+
const _package = packages.find((r) => r.uuid === item);
|
|
87
|
+
if (!_package) {
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
const displayName = `${_package.packageCode}-${_package.packageName}`;
|
|
91
|
+
return displayName;
|
|
92
|
+
}}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}}
|
|
89
96
|
/>
|
|
90
97
|
</Column>
|
|
91
98
|
<Column>
|
|
92
99
|
<PackageInterventions
|
|
93
100
|
categories={
|
|
94
101
|
packages
|
|
95
|
-
.filter((packages_) =>
|
|
96
|
-
|
|
102
|
+
.filter((packages_) => {
|
|
103
|
+
const isSelected = selectedPackageObservable.includes(packages_.uuid);
|
|
104
|
+
return isSelected;
|
|
105
|
+
})
|
|
106
|
+
?.map((p) => {
|
|
107
|
+
return p.packageCode;
|
|
108
|
+
}) ?? []
|
|
97
109
|
}
|
|
98
110
|
patientUuid={patientUuid}
|
|
99
111
|
/>
|
|
@@ -102,4 +114,4 @@ const SHABenefitPackangesAndInterventions: React.FC<Props> = ({ patientUuid }) =
|
|
|
102
114
|
);
|
|
103
115
|
};
|
|
104
116
|
|
|
105
|
-
export default
|
|
117
|
+
export default SHABenefitPackagesAndInterventions;
|
|
@@ -1,173 +1,50 @@
|
|
|
1
1
|
import { FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
2
|
import useSWR from 'swr';
|
|
4
|
-
import useFacilityLevel from './useFacilityLevel';
|
|
5
|
-
import { SHAIntervention } from '../types';
|
|
6
3
|
|
|
7
|
-
export
|
|
4
|
+
export interface InterventionsFilter {
|
|
8
5
|
package_code?: string;
|
|
9
|
-
scheme_code?: string;
|
|
10
6
|
applicable_gender?: 'MALE' | 'FEMALE';
|
|
11
|
-
}
|
|
7
|
+
}
|
|
12
8
|
|
|
13
9
|
interface Intervention {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
benefitCode: string;
|
|
21
|
-
benefitName: string;
|
|
22
|
-
guid: string;
|
|
23
|
-
created: string;
|
|
24
|
-
updated: string;
|
|
25
|
-
replicated: string;
|
|
26
|
-
owner: number;
|
|
27
|
-
needsPreauth: boolean;
|
|
28
|
-
levelsApplicable: string[];
|
|
29
|
-
paymentMechanism: string;
|
|
30
|
-
coverageLevel: string;
|
|
31
|
-
annualQuantityLimit: number;
|
|
32
|
-
annualQuantityLimitChoice: string;
|
|
33
|
-
annualQuantityLimitType: string;
|
|
34
|
-
overallTariff: string;
|
|
35
|
-
overallTariffHasLimit: boolean;
|
|
36
|
-
annualLimitValue: string;
|
|
37
|
-
usageFrequencyLimit: string;
|
|
38
|
-
usageFrequencyType: string;
|
|
39
|
-
status: string;
|
|
40
|
-
needsManualPreauthApproval: boolean;
|
|
41
|
-
needsDoctorAuthorization: boolean;
|
|
42
|
-
numberOfDoctorsRequired: string;
|
|
43
|
-
needsMemberAuthorization: boolean;
|
|
44
|
-
accessPoint: string;
|
|
45
|
-
name: string;
|
|
46
|
-
code: string;
|
|
47
|
-
active: boolean;
|
|
48
|
-
activeForUhc: boolean;
|
|
49
|
-
diagnosisBlock: string[];
|
|
50
|
-
diagnosisList: string[];
|
|
51
|
-
applicableGender: string;
|
|
52
|
-
applicableFacilityOwnership: string;
|
|
53
|
-
upperAgeLimit: string;
|
|
54
|
-
lowerAgeLimit: string;
|
|
55
|
-
investigationTariff: string;
|
|
56
|
-
investigationTariffHasLimit: boolean;
|
|
57
|
-
managementTariff: string;
|
|
58
|
-
managementTariffHasLimit: boolean;
|
|
59
|
-
isIntraMetro: boolean;
|
|
60
|
-
tariffPerAdditionalKilometer: string;
|
|
61
|
-
needApprovalBeforeClaimSubmission: boolean;
|
|
62
|
-
needsProtocols: boolean;
|
|
63
|
-
level_2_tariff: string;
|
|
64
|
-
level_3_tariff: string;
|
|
65
|
-
level_4_tariff: string;
|
|
66
|
-
level_5_tariff: string;
|
|
67
|
-
level_6_tariff: string;
|
|
68
|
-
protocolUsed: string;
|
|
69
|
-
tariffLimitPerIndividual: string;
|
|
70
|
-
complexity: string;
|
|
71
|
-
comment: string;
|
|
72
|
-
retiredOn: string;
|
|
73
|
-
requiresSurgicalPreauth: boolean;
|
|
74
|
-
requiresRenalPreauth: boolean;
|
|
75
|
-
requiresOncologyPreauth: boolean;
|
|
76
|
-
requiresRadiologyPreauth: boolean;
|
|
77
|
-
requiresOpticalPreauth: boolean;
|
|
78
|
-
applicableSchemes: string[];
|
|
79
|
-
benefit: number;
|
|
10
|
+
interventionCode: string;
|
|
11
|
+
interventionName: string;
|
|
12
|
+
interventionPackage: string;
|
|
13
|
+
interventionSubPackage: string;
|
|
14
|
+
interventionDescription?: string;
|
|
15
|
+
insuranceSchemes?: string;
|
|
80
16
|
}
|
|
81
17
|
|
|
82
18
|
/**
|
|
83
|
-
* Hook
|
|
84
|
-
* @param filters
|
|
85
|
-
* @returns
|
|
19
|
+
* Hook that returns a list of interventions based on filters
|
|
20
|
+
* @param filters - Filters for interventions (package_code, applicable_gender)
|
|
21
|
+
* @returns
|
|
86
22
|
*/
|
|
87
|
-
export const useInterventions = (filters
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
// Build URL parameters for the API call
|
|
91
|
-
const urlParams = new URLSearchParams({
|
|
92
|
-
...(filters || {}),
|
|
93
|
-
synchronize: 'false',
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
const url = `${restBaseUrl}/kenyaemr/sha-interventions?${urlParams.toString()}`;
|
|
97
|
-
const { isLoading, error, data } = useSWR<FetchResponse<{ results: Array<Intervention> }>>(url, openmrsFetch);
|
|
98
|
-
|
|
99
|
-
// Mapper function to transform intervention data
|
|
100
|
-
const mapper = ({ code, name, parentBenefitCode }: Intervention): SHAIntervention => ({
|
|
101
|
-
interventionCode: code,
|
|
102
|
-
interventionName: name,
|
|
103
|
-
interventionPackage: parentBenefitCode,
|
|
104
|
-
...({} as any),
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
// Filter and map interventions
|
|
108
|
-
const interventions = useMemo(() => {
|
|
109
|
-
if (!data?.data?.results) {
|
|
110
|
-
return [];
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const packageCodes = filters.package_code?.split(',').filter(Boolean) || [];
|
|
114
|
-
|
|
115
|
-
const filteredResults = data.data.results.filter((intervention, i) => {
|
|
116
|
-
// Filter by package code (only if defined)
|
|
117
|
-
|
|
118
|
-
if (packageCodes.length > 0 && !packageCodes.includes(intervention.parentBenefitCode)) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Filter by applicable gender (only if defined)
|
|
123
|
-
if (
|
|
124
|
-
filters.applicable_gender &&
|
|
125
|
-
intervention.applicableGender &&
|
|
126
|
-
!['ALL', filters.applicable_gender].includes(intervention.applicableGender)
|
|
127
|
-
) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// // Filter by facility level
|
|
132
|
-
if (level && intervention.levelsApplicable && Array.isArray(intervention.levelsApplicable)) {
|
|
133
|
-
// Check if level starts with any of the intervention.levelsApplicable values
|
|
134
|
-
const levelMatched = intervention.levelsApplicable.some((appLevel) => level.startsWith(appLevel));
|
|
135
|
-
|
|
136
|
-
if (!levelMatched) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return true; // Keep item if it passes all filters
|
|
142
|
-
});
|
|
23
|
+
export const useInterventions = (filters?: InterventionsFilter) => {
|
|
24
|
+
const params = new URLSearchParams();
|
|
143
25
|
|
|
144
|
-
|
|
145
|
-
|
|
26
|
+
if (filters?.package_code) {
|
|
27
|
+
params.append('package_code', filters.package_code);
|
|
28
|
+
}
|
|
146
29
|
|
|
147
|
-
|
|
148
|
-
|
|
30
|
+
if (filters?.applicable_gender) {
|
|
31
|
+
params.append('applicable_gender', filters.applicable_gender.toLowerCase());
|
|
32
|
+
}
|
|
149
33
|
|
|
150
|
-
|
|
151
|
-
const allInterventions = useMemo(() => {
|
|
152
|
-
if (!data?.data?.results) {
|
|
153
|
-
return [];
|
|
154
|
-
}
|
|
34
|
+
const url = `${restBaseUrl}/insclaims/interventions?${params.toString()}`;
|
|
155
35
|
|
|
156
|
-
|
|
157
|
-
const mappedInterventions = data.data.results.map(mapper);
|
|
36
|
+
const allInterventionsUrl = `${restBaseUrl}/insclaims/interventions`;
|
|
158
37
|
|
|
159
|
-
|
|
160
|
-
const uniqueInterventions = Array.from(
|
|
161
|
-
new Map(mappedInterventions.map((item) => [item.interventionCode, item])),
|
|
162
|
-
).map(([, value]) => value);
|
|
38
|
+
const { data, isLoading, error } = useSWR<FetchResponse<{ data: Array<Intervention> }>>(url, openmrsFetch);
|
|
163
39
|
|
|
164
|
-
|
|
165
|
-
}, [data]);
|
|
40
|
+
const { data: allData } = useSWR<FetchResponse<{ data: Array<Intervention> }>>(allInterventionsUrl, openmrsFetch);
|
|
166
41
|
|
|
42
|
+
const interventions = data?.data?.data ?? [];
|
|
43
|
+
const allInterventions = allData?.data?.data ?? [];
|
|
167
44
|
return {
|
|
168
|
-
isLoading
|
|
169
|
-
interventions
|
|
170
|
-
allInterventions
|
|
171
|
-
error
|
|
45
|
+
isLoading,
|
|
46
|
+
interventions,
|
|
47
|
+
allInterventions,
|
|
48
|
+
error,
|
|
172
49
|
};
|
|
173
50
|
};
|
package/src/hooks/usePackages.ts
CHANGED
|
@@ -2,27 +2,40 @@ import { FetchResponse, openmrsFetch, restBaseUrl } from '@openmrs/esm-framework
|
|
|
2
2
|
import useSWR from 'swr';
|
|
3
3
|
import { Package } from '../types';
|
|
4
4
|
|
|
5
|
+
interface PackagesFilter {
|
|
6
|
+
applicable_gender?: 'male' | 'female';
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
|
-
* Hook that
|
|
10
|
+
* Hook that returns a list of SHA benefits category/packages
|
|
11
|
+
* @param filters - Optional filters for packages
|
|
7
12
|
* @returns
|
|
8
13
|
*/
|
|
9
|
-
const usePackages = () => {
|
|
10
|
-
const
|
|
14
|
+
const usePackages = (filters?: PackagesFilter) => {
|
|
15
|
+
const params = new URLSearchParams();
|
|
16
|
+
|
|
17
|
+
if (filters?.applicable_gender) {
|
|
18
|
+
params.append('applicable_gender', filters.applicable_gender);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const url = `${restBaseUrl}/insclaims/packages?${params.toString()}`;
|
|
11
22
|
|
|
12
|
-
const { data, isLoading, error } = useSWR<
|
|
13
|
-
|
|
14
|
-
|
|
23
|
+
const { data, isLoading, error } = useSWR<FetchResponse<Array<{ code: string; name: string; description?: string }>>>(
|
|
24
|
+
url,
|
|
25
|
+
openmrsFetch,
|
|
26
|
+
);
|
|
15
27
|
|
|
28
|
+
const packages = (data?.data ?? []).map((category) => {
|
|
29
|
+
const pkg = {
|
|
30
|
+
uuid: `${category.code}`,
|
|
31
|
+
packageCode: category.code,
|
|
32
|
+
packageName: category.name,
|
|
33
|
+
} as Package;
|
|
34
|
+
return pkg;
|
|
35
|
+
});
|
|
16
36
|
return {
|
|
17
37
|
isLoading,
|
|
18
|
-
packages
|
|
19
|
-
(category) =>
|
|
20
|
-
({
|
|
21
|
-
uuid: `${category.benefitCode}`,
|
|
22
|
-
packageCode: category.benefitCode,
|
|
23
|
-
packageName: category.benefitName,
|
|
24
|
-
} as Package),
|
|
25
|
-
),
|
|
38
|
+
packages,
|
|
26
39
|
error,
|
|
27
40
|
};
|
|
28
41
|
};
|
package/translations/am.json
CHANGED
|
@@ -130,8 +130,8 @@
|
|
|
130
130
|
"error": "ስህተት",
|
|
131
131
|
"errored": "ስህተት ተፈጥሯል",
|
|
132
132
|
"errorEndingVisit": "ጉብኝት በመጨረስ ላይ ስህተት",
|
|
133
|
-
"errorFetchingPackages": "ጥቅሎችን በማምጣት ላይ ስህተት",
|
|
134
133
|
"errorLoadingBillServices": "የሂሳብ አገልግሎቶችን በመጫን ላይ ስህተት",
|
|
134
|
+
"errorLoadingData": "Error loading data",
|
|
135
135
|
"errorLoadingpackages": "ጥቅሎችን በመጫን ላይ ስህተት",
|
|
136
136
|
"errorLoadingPaymentModes": "የክፍያ ዘዴዎች ስህተት",
|
|
137
137
|
"errorLoadingPaymentPoints": "የክፍያ ነጥቦችን በመጫን ላይ ስህተት",
|
package/translations/en.json
CHANGED
|
@@ -130,8 +130,8 @@
|
|
|
130
130
|
"error": "Error",
|
|
131
131
|
"errored": "Errored",
|
|
132
132
|
"errorEndingVisit": "Error ending visit",
|
|
133
|
-
"errorFetchingPackages": "Error fetching packeges",
|
|
134
133
|
"errorLoadingBillServices": "Error loading bill services",
|
|
134
|
+
"errorLoadingData": "Error loading data",
|
|
135
135
|
"errorLoadingpackages": "Error loading packages",
|
|
136
136
|
"errorLoadingPaymentModes": "Payment modes error",
|
|
137
137
|
"errorLoadingPaymentPoints": "Error loading payment points",
|
package/translations/sw.json
CHANGED
|
@@ -130,8 +130,8 @@
|
|
|
130
130
|
"error": "Error",
|
|
131
131
|
"errored": "Errored",
|
|
132
132
|
"errorEndingVisit": "Error ending visit",
|
|
133
|
-
"errorFetchingPackages": "Error fetching packeges",
|
|
134
133
|
"errorLoadingBillServices": "Error loading bill services",
|
|
134
|
+
"errorLoadingData": "Error loading data",
|
|
135
135
|
"errorLoadingpackages": "Error loading packages",
|
|
136
136
|
"errorLoadingPaymentModes": "Payment modes error",
|
|
137
137
|
"errorLoadingPaymentPoints": "Error loading payment points",
|