Skip to content

Commit 74c8a3a

Browse files
authored
Merge pull request ReproNim#65 from Evan8456/main
Fixed bug in redcap2reproschema with items id not matching item filname and redcap variable…
2 parents 4b3c3d2 + 82ec3c4 commit 74c8a3a

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

reproschema/redcap2reproschema.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
from .jsonldutils import get_context_version
1111
from .models import Activity, Item, Protocol, write_obj_jsonld
1212

13-
matrix_group_count = {}
14-
1513
# All the mapping used in the code
1614
SCHEMA_MAP = {
1715
"Variable / Field Name": "@id", # column A
@@ -252,18 +250,9 @@ def process_row(
252250
add_preable=True,
253251
):
254252
"""Process a row of the REDCap data and generate the jsonld file for the item."""
255-
global matrix_group_count
256-
matrix_group_name = field.get("Matrix Group Name", "")
257-
if matrix_group_name:
258-
matrix_group_count[matrix_group_name] = (
259-
matrix_group_count.get(matrix_group_name, 0) + 1
260-
)
261-
item_id = (
262-
f"{matrix_group_name}_{matrix_group_count[matrix_group_name]}"
263-
)
264-
else:
265-
item_id = field.get("Variable / Field Name", "")
266-
253+
item_id = field.get(
254+
"Variable / Field Name", ""
255+
) # item_id should always be the Variable name in redcap
267256
rowData = {
268257
"category": "reproschema:Item",
269258
"id": item_id,
@@ -349,7 +338,7 @@ def process_row(
349338
"activities",
350339
form_name,
351340
"items",
352-
f'{field["Variable / Field Name"]}',
341+
item_id,
353342
)
354343

355344
write_obj_jsonld(it, file_path_item, contextfile_url=schema_context_url)

0 commit comments

Comments
 (0)