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
Making it so conditional polyp fields are shown
Updating markdown doc to show how to add custom input types that are not enums or any of the already available ones.
-`Enum` type name (e.g., `"DrugTypeOptions"`, `"YesNoOptions"`): Dropdown with `enum` values.<br>
108
+
-`Enum` type name (e.g., `"DrugTypeOptions"`, `"YesNoOptions"`): Dropdown with `enum` values.
109
+
-**Custom types**: See [Adding Custom Types](#adding-custom-types) below.<br>
108
110
109
111
-`"description"`:<br>
110
112
A clear description of the field, shown in the UI.
@@ -309,6 +311,44 @@ If you add new `Enum` types to `pages.datasets.investigation_dataset_page`, you
309
311
310
312
---
311
313
314
+
### Adding Custom Types
315
+
316
+
You can add custom types for fields that do not fit the standard types or enums.
317
+
Examples include `"yes_no"` and `"therapeutic_diagnostic"`, which are handled as special dropdowns in the UI.
318
+
319
+
**To add a custom type:**
320
+
321
+
1. Choose a unique string for `"type"` (e.g., `"yes_no"`, `"therapeutic_diagnostic"`).
322
+
2. In your JSON field definition, set `"type"` to this string.
323
+
3. Ensure your `render_field` function in `investigation_dataset_ui.py` has a case for your custom type, rendering the appropriate widget (usually a dropdown/selectbox).
324
+
- For `"yes_no"`, the UI will show a dropdown with "yes" and "no".
325
+
- For `"therapeutic_diagnostic"`, the UI will show a dropdown with "therapeutic" and "diagnostic".
326
+
4. You can add more custom types by extending the `render_field` function with new cases in the `match-case` or `if` dispatch.
327
+
328
+
**Example:**
329
+
330
+
`dataset_fields.json`:
331
+
332
+
```json
333
+
{
334
+
"key": "procedure type",
335
+
"type": "therapeutic_diagnostic",
336
+
"description": "If it was a procedure or diagnostic testing",
0 commit comments