Skip to content

Commit

Permalink
FIx Location creation (#1269)
Browse files Browse the repository at this point in the history
* Add a docstring about what identifier is used on location list

* Replace nodid to include resourceType
  • Loading branch information
peterMuriuki authored Sep 28, 2023
1 parent d9f97fe commit fa3578a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
2 changes: 1 addition & 1 deletion packages/fhir-location-management/src/helpers/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const useGetLocationsAsHierarchy = (baseUrl: string, rootIdentifier: stri
select: (res: IBundle) => {
const rawLocations = cloneDeep(getResourcesFromBundle<ILocation>(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) {
Expand Down

0 comments on commit fa3578a

Please sign in to comment.