You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -255,37 +256,55 @@ If integrating with CommCare `forms`, you may need to make sure that any unique
255
256
256
257
### Lookup Tables in CommCare
257
258
Lookup tables in CommCare store reference data that can be used across multiple forms and workflows. They are often used for predefined lists such as as health facility names, geographic locations, product catalogs, or standardized response options.
259
+
258
260
When fetching lookup table data in using CommCare APIs, there are two main approaches:
259
261
**1. Using the Fixture API**
262
+
[See here](https://commcare-hq.readthedocs.io/api/fixture.html) for the CommCare docs on this API. FYI `fixture` is a more technical term that the CommCare docs sometimes use to refer to a `lookup table`.
260
263
```
264
+
//sample openfn job to get a specific 'diagnosis' lookup table
261
265
get("fixture/?fixture_type=diagnosis")
262
266
```
263
267
264
268
**Pros:**
265
-
- Simple and direct for fetching specific tables.
266
-
- Works well when only a few tables (e.g., 2-3) are needed.
269
+
- Simple and direct API for querying a specific lookup table; response include lookup table metadata and data.
270
+
- Works well when items from only a couple of tables (e.g., 1-3) need to be queried.
271
+
267
272
**Cons:**
268
-
- Requires multiple API calls if several tables are needed, which can be inefficient.
273
+
- Requires multiple API calls if several tables are needed, which can be inefficient at scale.
274
+
- See `lookup_table_item` API if querying data across multiple lookup tables.
- Fetches all lookup tables in a single request, reducing API calls.
281
-
- Useful for OpenFn workflows requiring multiple lookup tables.
296
+
- Good for bulk querying lookup table rows in a single request, reducing API calls.
297
+
- Useful for OpenFn workflows requiring data from multiple lookup tables.
298
+
- Support for create & update of lookup table items.
299
+
282
300
**Cons:**
283
301
- Retrieves all lookup tables and filters them in-memory, which can be inefficient if only a few tables are needed.
284
302
285
303
#### Best Practices
286
-
- Use the Fixture API when fetching only a few lookup tables.
287
-
- Use the lookup_table_item API for cases where multiple lookup tables are needed at once.
304
+
- Use the `Fixture` API when fetching data for only a couple of (1-3) lookup tables.
305
+
- Use the `lookup_table` API for scenarios where data from multiple lookup tables needs to be queried in bulk.
288
306
- Consider performance trade-offs when selecting an approach, balancing API efficiency with data processing overhead.
307
+
- See the [bulk()](/adaptors/packages/commcare-docs#bulk) helper function for bulk importing lookup table data.
289
308
290
309
#### Troubleshooting tips
291
310
If some tables are throwing errors when being fetched using the fixtures API, the lookup table might be corrupt. Consider exporting the table and re-importing it.
0 commit comments