Skip to content

Commit 9e720f4

Browse files
committed
allowing choices for type=text to include information about item from ontology
1 parent c14864e commit 9e720f4

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

reproschema/redcap2reproschema.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,17 @@ def process_response_options(row, input_type_rc, value_type) -> Dict[str, Any]:
106106
response_options["multipleChoice"] = True
107107

108108
if row.get("choices") and input_type:
109-
if input_type in [
110-
"radio",
111-
"select",
112-
"slider",
113-
]:
109+
if input_type in ["radio", "select", "slider", "text"]:
114110
choices, choices_val_type_l = process_choices(
115111
row.get("choices"), item_name=row["item_name"]
116112
)
117-
response_options.update(
118-
{
119-
"choices": choices,
120-
"valueType": choices_val_type_l,
121-
}
122-
)
113+
if choices:
114+
response_options.update(
115+
{
116+
"choices": choices,
117+
"valueType": choices_val_type_l,
118+
}
119+
)
123120
if input_type == "slider":
124121
response_options.update(
125122
{
@@ -181,7 +178,7 @@ def process_choices(choices_str, item_name):
181178
parts = choice.split(",", 1)
182179
if len(parts) < 2:
183180
print(f"Warning: Invalid choice format '{choice}' in {item_name}")
184-
continue
181+
parts = parts * 2 # assuming the same value as label
185182

186183
value_part = parts[0].strip()
187184
label_part = parts[1].strip()

0 commit comments

Comments
 (0)