Skip to content

Commit 10350dd

Browse files
committed
set up ui readonly
1 parent e72180a commit 10350dd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

reproschema/redcap2reproschema.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,19 +327,28 @@ def process_row(
327327

328328
field_type = field.get("Field Type", "")
329329
input_type, value_type = parse_field_type_and_value(field)
330-
rowData["ui"] = {"inputType": input_type}
330+
331+
# Initialize ui object with common properties
332+
ui_obj = {"inputType": input_type}
333+
334+
# Handle readonly status first - this affects UI behavior
335+
annotation = str(field.get("Field Annotation", "")).upper()
336+
if (field_type in COMPUTE_LIST or
337+
"@READONLY" in annotation or
338+
"@CALCTEXT" in annotation):
339+
ui_obj["readonlyValue"] = True
340+
341+
rowData["ui"] = ui_obj
331342
rowData["responseOptions"] = {"valueType": [value_type]}
332343

333-
# setting additional fields for some field types
344+
# Handle specific field type configurations
334345
if field_type == "yesno":
335346
rowData["responseOptions"]["choices"] = [
336347
{"name": {"en": "Yes"}, "value": 1},
337348
{"name": {"en": "No"}, "value": 0},
338349
]
339350
elif field_type == "checkbox":
340351
rowData["responseOptions"]["multipleChoice"] = True
341-
elif field_type in COMPUTE_LIST:
342-
rowData["ui"]["readonlyValue"] = True
343352

344353
for key, value in field.items():
345354
if SCHEMA_MAP.get(key) in ["question", "description"] and value:

0 commit comments

Comments
 (0)