diff --git a/packages/fhir-location-management/src/components/LocationUnitList/index.tsx b/packages/fhir-location-management/src/components/LocationUnitList/index.tsx index b880c20ab..2a3166bad 100644 --- a/packages/fhir-location-management/src/components/LocationUnitList/index.tsx +++ b/packages/fhir-location-management/src/components/LocationUnitList/index.tsx @@ -28,7 +28,7 @@ reducerRegistry.register(reducerName, reducer); interface LocationUnitListProps { fhirBaseURL: string; - fhirRootLocationIdentifier: string; + fhirRootLocationIdentifier: string; // This is the location.id field. } export interface AntTreeData { diff --git a/packages/fhir-location-management/src/helpers/flat-to-nested.ts b/packages/fhir-location-management/src/helpers/flat-to-nested.ts index 26d3bbd4e..b44b78ac0 100644 --- a/packages/fhir-location-management/src/helpers/flat-to-nested.ts +++ b/packages/fhir-location-management/src/helpers/flat-to-nested.ts @@ -18,7 +18,7 @@ export function nestLocations(locations: ILocation[]) { for (let i = 0, len = locations.length; i < len; i++) { const rawLocation = locations[i]; const location = { - nodeId: rawLocation.id as string, + nodeId: `${rawLocation.resourceType}/${rawLocation.id}`, label: rawLocation.name ?? '', node: rawLocation, }; diff --git a/packages/fhir-location-management/src/helpers/tests/utils.test.ts b/packages/fhir-location-management/src/helpers/tests/utils.test.ts index c6b0907b2..59c9e11bf 100644 --- a/packages/fhir-location-management/src/helpers/tests/utils.test.ts +++ b/packages/fhir-location-management/src/helpers/tests/utils.test.ts @@ -69,4 +69,5 @@ test('can create tree from flat array of locations', () => { const tree = new TreeModel().parse(roots[0]); expect(tree.model.node.id).toEqual('2252'); + expect(tree.model.nodeId).toEqual('Location/2252'); }); diff --git a/packages/fhir-location-management/src/helpers/utils.ts b/packages/fhir-location-management/src/helpers/utils.ts index c81364bdc..f875b16a2 100644 --- a/packages/fhir-location-management/src/helpers/utils.ts +++ b/packages/fhir-location-management/src/helpers/utils.ts @@ -93,7 +93,7 @@ export const useGetLocationsAsHierarchy = (baseUrl: string, rootIdentifier: stri select: (res: IBundle) => { const rawLocations = cloneDeep(getResourcesFromBundle(res)); const nested = nestLocations(rawLocations); - const interestingRoot = nested.filter((root) => root.nodeId === `${rootIdentifier}`)[0] as + const interestingRoot = nested.filter((root) => root.node.id === `${rootIdentifier}`)[0] as | CommonHierarchyNode | undefined; if (!interestingRoot) {