@kenyaemr/esm-admin-app 5.4.2-pre.2767 → 5.4.2-pre.2774

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/dist/routes.json CHANGED
@@ -1 +1 @@
1
- {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemrCharts":"^1.6.7"},"extensions":[{"component":"adminLeftPanelLink","name":"admin-left-panel-link","slot":"admin-left-panel-slot"},{"component":"userManagementLeftPannelLink","name":"user-management-left-panel-link","slot":"admin-left-panel-slot"},{"component":"etlAdministrationLeftPannelLink","name":"etl-administration-left-panel-link","slot":"admin-left-panel-slot"},{"component":"locationsLeftPanelLink","name":"locations-left-panel-link","slot":"admin-left-panel-slot"},{"component":"facilitySetupLeftPanelLink","name":"facility-setup-left-panel-link","slot":"admin-left-panel-slot"},{"component":"providerBanner","name":"provider-banner","slot":"provider-banner-info-slot","order":1}],"workspaces":[{"name":"manage-user-workspace","component":"manageUserWorkspace","title":"Manage User Workspace","type":"other-form","canMaximize":true,"width":"extra-wide"},{"name":"user-role-scope-workspace","component":"userRoleScopeWorkspace","title":"User Rple Scope Workspace","type":"other-form","canMaximize":true,"width":"extra-wide"},{"name":"add-location-workspace","title":"Add Location","component":"addLocation","type":"workspace"},{"name":"search-location-workspace","title":"Search Location","component":"searchLocationWorkspace","type":"workspace"},{"name":"hwr-sync-workspace","title":"HWR Sync Workspace","component":"hwrSyncWorkspace","type":"other-form"},{"name":"hwr-sync-modal","title":"HWR Sync Modal","component":"hwrSyncModal","type":"modal"}],"modals":[{"component":"operationConfirmationModal","name":"operation-confirmation-modal"},{"component":"hwrConfirmationModal","name":"hwr-confirmation-modal"},{"component":"hwrEmptyModal","name":"hwr-empty-modal"},{"component":"hwrSyncModal","name":"hwr-syncing-modal"}],"pages":[{"component":"root","route":"admin"}],"version":"5.4.2-pre.2767"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemrCharts":"^1.6.7"},"extensions":[{"component":"adminLeftPanelLink","name":"admin-left-panel-link","slot":"admin-left-panel-slot"},{"component":"userManagementLeftPannelLink","name":"user-management-left-panel-link","slot":"admin-left-panel-slot"},{"component":"etlAdministrationLeftPannelLink","name":"etl-administration-left-panel-link","slot":"admin-left-panel-slot"},{"component":"locationsLeftPanelLink","name":"locations-left-panel-link","slot":"admin-left-panel-slot"},{"component":"facilitySetupLeftPanelLink","name":"facility-setup-left-panel-link","slot":"admin-left-panel-slot"},{"component":"providerBanner","name":"provider-banner","slot":"provider-banner-info-slot","order":1}],"workspaces":[{"name":"manage-user-workspace","component":"manageUserWorkspace","title":"Manage User Workspace","type":"other-form","canMaximize":true,"width":"extra-wide"},{"name":"user-role-scope-workspace","component":"userRoleScopeWorkspace","title":"User Rple Scope Workspace","type":"other-form","canMaximize":true,"width":"extra-wide"},{"name":"add-location-workspace","title":"Add Location","component":"addLocation","type":"workspace"},{"name":"search-location-workspace","title":"Search Location","component":"searchLocationWorkspace","type":"workspace"},{"name":"hwr-sync-workspace","title":"HWR Sync Workspace","component":"hwrSyncWorkspace","type":"other-form"},{"name":"hwr-sync-modal","title":"HWR Sync Modal","component":"hwrSyncModal","type":"modal"}],"modals":[{"component":"operationConfirmationModal","name":"operation-confirmation-modal"},{"component":"hwrConfirmationModal","name":"hwr-confirmation-modal"},{"component":"hwrEmptyModal","name":"hwr-empty-modal"},{"component":"hwrSyncModal","name":"hwr-syncing-modal"}],"pages":[{"component":"root","route":"admin"}],"version":"5.4.2-pre.2774"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-admin-app",
3
- "version": "5.4.2-pre.2767",
3
+ "version": "5.4.2-pre.2774",
4
4
  "description": "Facilitates the management of ETL tables",
5
5
  "keywords": [
6
6
  "openmrs"
@@ -1,41 +1,26 @@
1
- import { FetchResponse, fhirBaseUrl, openmrsFetch, useFhirFetchAll } from '@openmrs/esm-framework';
2
- import { type FHIRBundle, FHIRLocation, LocationTagsResponse } from '../types';
3
- import useSWR from 'swr';
1
+ import { useFhirFetchAll } from '@openmrs/esm-framework';
2
+ import { type FHIRLocation, type LocationTagsResponse } from '../types';
4
3
 
5
4
  /**
6
- * Fetches facilities that are tagged with any of the specified location tags.
5
+ * Custom hook that fetches all facilities with specified location tags.
6
+ * Uses the framework's useFhirFetchAll hook which handles pagination automatically.
7
7
  *
8
- * @param locationTags The location tags to filter facilities by
9
- * @returns A promise that resolves to the data object containing the matching FHIR locations
10
- * @throws {Error} If the API request fails
8
+ * @param locationTags The location tags response containing tags to filter by
9
+ * @returns Object containing loading state, error, and the list of facilities
11
10
  */
12
- export async function getFacilitiesByLocationTags(
13
- locationTags: LocationTagsResponse,
14
- ): Promise<{ results: Array<FHIRLocation> }> {
15
- const tagNames = locationTags.results
16
- .map((tag) => encodeURIComponent(tag.name || tag.display))
11
+ export const useFacilitiesTagged = (locationTags: LocationTagsResponse) => {
12
+ const tagNames = locationTags?.results
13
+ ?.map((tag) => encodeURIComponent(tag.name || tag.display))
17
14
  .filter(Boolean)
18
15
  .join(',');
19
16
 
20
- const url = `${useFhirFetchAll}/Location?_summary=data&_tag=${tagNames}`;
21
- const response = await openmrsFetch<FHIRBundle>(url);
22
-
23
- const locations = response.data?.entry?.map((entry) => entry.resource) ?? [];
24
-
25
- return { results: locations };
26
- }
17
+ const url = tagNames ? `ws/fhir2/R4/Location?_summary=data&_tag=${tagNames}` : null;
27
18
 
28
- export const useFacilitiesTagged = (locationTags: LocationTagsResponse) => {
29
- const tagNames = locationTags.results
30
- .map((tag) => encodeURIComponent(tag.name || tag.display))
31
- .filter(Boolean)
32
- .join(',');
33
- const url = `${fhirBaseUrl}/Location?_summary=data&_tag=${tagNames}`;
34
- const { isLoading, error, data } = useSWR<FetchResponse<FHIRBundle>>(url, openmrsFetch);
19
+ const { data, isLoading, error } = useFhirFetchAll<FHIRLocation>(url);
35
20
 
36
21
  return {
37
22
  isLoading,
38
23
  error,
39
- facilityList: data?.data?.entry || [],
24
+ facilityList: data?.map((resource) => ({ resource })) || [],
40
25
  };
41
26
  };