Skip to content

feat: ✨ add ability to download data dict from REDCap#33

Open
martonvago wants to merge 8 commits intomainfrom
feat/redcap-data-dict
Open

feat: ✨ add ability to download data dict from REDCap#33
martonvago wants to merge 8 commits intomainfrom
feat/redcap-data-dict

Conversation

@martonvago
Copy link
Collaborator

Description

This PR adds the ability to download the data dict from REDCap.

Closes #24

This PR needs an in-depth review.

Checklist

  • Formatted Markdown
  • Ran just run-all


def get_data_dict_from_redcap() -> dict[str, str]:
"""Gets the data dictionary from REDCap."""
token = os.environ.get("REDCAP_TOKEN")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the token has CPH_API_KEY in the name on GenomeDK. Should we keep the reference to CPH? I went with a more general name here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for the generic code we should use the more general name, for the implementation of this code on ON LiMiT Feasibility we'll need to know that this is the code for the instance on REDCap in Copenhagen. Later there will be tokens for Copenhagen, Aarhus and Odense.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will all the locations be in the same repo or different repos?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the REDCap locations will pull into this one Data Package repo, as far I know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay! The metadata will be exactly the same, right (it's enough to get it from one location)? Then I will change the token name back to the CPH-specific one.

@martonvago martonvago moved this from Todo to In Review in Data development Mar 19, 2026
@martonvago martonvago marked this pull request as ready for review March 19, 2026 10:17
Copy link
Member

@lwjohnst86 lwjohnst86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, just some minor comments


def get_data_dict_from_redcap() -> dict[str, str]:
"""Gets the data dictionary from REDCap."""
token = os.environ.get("REDCAP_TOKEN")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the REDCap locations will pull into this one Data Package repo, as far I know.

@github-project-automation github-project-automation bot moved this from In Review to In Progress in Data development Mar 23, 2026
@lwjohnst86
Copy link
Member

@martonvago you can also include the downloaded data_dictionary.json file here, so that we can do work on it outside of GenomeDK (it's only metadata).

Comment on lines +37 to +38
if __name__ == "__main__":
save_data_dict()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be able to run it from the justfile nicely. We can also call other functions (e.g., getting form metadata) from here later.

@martonvago
Copy link
Collaborator Author

martonvago commented Mar 23, 2026

@martonvago you can also include the downloaded data_dictionary.json file here, so that we can do work on it outside of GenomeDK (it's only metadata).

@lwjohnst86 as in include it in the repo? Oh I'm stupid I was thinking why would I include the test metadata. But you meant the real metadata 🤦

@martonvago martonvago requested a review from lwjohnst86 March 23, 2026 15:22
@martonvago martonvago moved this from In Progress to In Review in Data development Mar 23, 2026
"format": "json",
"returnFormat": "json",
}
response = requests.post("https://redcap.au.dk/api/", data=data, timeout=30)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the address of the real API?
I tried running the script on GenomeDK with the CPH token and got forbidden. The test setup works on GenomeDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

Extract data dictionary flow

3 participants