@kenyaemr/esm-billing-app 5.4.1-pre.1935 → 5.4.1-pre.1936

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.
@@ -8,6 +8,7 @@ export interface BillingConfig {
8
8
  policyNumber: string;
9
9
  exemptionCategory: string;
10
10
  billPaymentStatus: string;
11
+ shaBenefitPackagesAndInterventions: string;
11
12
  };
12
13
  insurancePaymentMethod: string;
13
14
  inPatientVisitTypeUuid: string;
@@ -96,6 +97,11 @@ export const configSchema: ConfigSchema = {
96
97
  _description: 'The bill payment status visit attribute uuid',
97
98
  _default: '919b51c9-8e2e-468f-8354-181bf3e55786',
98
99
  },
100
+ shaBenefitPackagesAndInterventions: {
101
+ _type: Type.String,
102
+ _description: 'JSON String of SHA Benefit Packages and Interventions for this visit',
103
+ _default: '338725fa-3790-4679-98b9-be623214ee29',
104
+ },
99
105
  },
100
106
  insurancePaymentMethod: {
101
107
  _type: Type.String,
package/src/constants.ts CHANGED
@@ -20,3 +20,4 @@ export const colorsArray = [
20
20
  // Size in MegaBits
21
21
  export const MAX_ALLOWED_FILE_SIZE = 2097152;
22
22
  export const PAYMENT_MODE_ATTRIBUTE_FORMATS = ['java.lang.String', 'java.lang.Integer', 'java.lang.Double'];
23
+ export const SHA_INSURANCE_SCHEME = 'SHA';
@@ -10,20 +10,6 @@ export type InterventionsFilter = {
10
10
  applicable_gender?: 'MALE' | 'FEMALE';
11
11
  };
12
12
 
13
- export const toQueryParams = (q: Record<string, any>) => {
14
- return (
15
- '?' +
16
- Object.entries(q)
17
- .reduce((prev, [key, val]) => {
18
- if (val !== undefined && val !== null) {
19
- return [...prev, `${key}=${val}`];
20
- }
21
- return prev;
22
- }, [])
23
- .join('&')
24
- );
25
- };
26
-
27
13
  type Data = {
28
14
  status: string;
29
15
  data: Array<{
@@ -56,17 +42,18 @@ export const useInterventions = (filters: InterventionsFilter) => {
56
42
  };
57
43
 
58
44
  const { error: facilityLevelError, isLoading: isLoadingFacilityLevel, level } = useFacilityLevel();
59
-
60
- const url = `${restBaseUrl}/kenyaemr/sha-interventions${toQueryParams({
45
+ const urlParams = new URLSearchParams({
61
46
  ...filters,
62
- synchronize: false,
63
- })}`;
47
+ synchronize: 'false',
48
+ });
49
+ const url = `${restBaseUrl}/kenyaemr/sha-interventions?${urlParams.toString()}`;
64
50
  const { isLoading, error, data } = useSWR<FetchResponse<Data>>(url, openmrsFetch);
65
51
  const interventions = useMemo(() => {
52
+ const packageCodes = filters.package_code?.split(',') || [];
66
53
  return data?.data?.data
67
54
  ?.filter((d) => {
68
55
  // 1. Filter by package code (only if defined)
69
- if (filters.package_code && d.interventionPackage !== filters.package_code) {
56
+ if (packageCodes.length > 0 && !packageCodes.includes(d.interventionPackage)) {
70
57
  return false;
71
58
  }
72
59
 
@@ -106,12 +93,23 @@ export const useInterventions = (filters: InterventionsFilter) => {
106
93
  interventionCode,
107
94
  subCategoryBenefitsPackage: interventionSubPackage,
108
95
  interventionName,
96
+ interventionPackage,
109
97
  })) as SHAIntervention[];
110
98
  }, [data, filters, level]); // Ensure proper memoization
111
-
99
+ const allInterventions = useMemo(() => {
100
+ return (data?.data?.data ?? []).map(
101
+ ({ interventionCode, interventionName, interventionPackage, interventionSubPackage }) => ({
102
+ interventionCode,
103
+ subCategoryBenefitsPackage: interventionSubPackage,
104
+ interventionName,
105
+ interventionPackage,
106
+ }),
107
+ ) as SHAIntervention[];
108
+ }, [data]);
112
109
  return {
113
110
  isLoading: isLoading || isLoadingFacilityLevel,
114
- interventions,
111
+ interventions: interventions ?? [],
112
+ allInterventions,
115
113
  error: error || facilityLevelError,
116
114
  };
117
115
  };
@@ -493,6 +493,7 @@ export type PaymentMode = {
493
493
 
494
494
  export type SHAIntervention = {
495
495
  interventionCode: string;
496
+ interventionPackage: string;
496
497
  shaCategory: string;
497
498
  accessCode: string;
498
499
  subCategoryBenefitsPackage: string;