Closed Wkt8 closed 8 months ago
Amnon has a temporary login account to the REDCAP API
json_format.json REDCAP Data Dictionary in the form of a JSON schema in the attached file
Possible access methods to the catalogue data: Catalogue Data Access_Page 1.pdf
This is now complete as we have the json schema of the REDCAP Data Dictionary.
import requests as rq
import json
data = {
'token': '-',
'content': 'metadata',
'format': 'json',
'returnFormat': 'json',
}
r = rq.post('https://redcap.h3abionet.org/redcap/api/',data=data)
print('HTTP Status: ' + str(r.status_code))
# print(r.json())
redcap_data = r.json()
# Convert REDCap data to HAL format
hal_data = {
"_links": {
"self": {"href": "/redcap"}
},
"_embedded": {
"properties": []
}
}
for record in redcap_data:
record_data = {record["field_name"]:
{
"form_name":record["form_name"],
"type": record["field_type"],
"select_choices_or_calculations": record["select_choices_or_calculations"],
"required_field": record["required_field"],
"text_validation_type_or_show_slider_number": record["text_validation_type_or_show_slider_number"],
"text_validation_min": record["text_validation_min"],
"text_validation_max": record["text_validation_max"]
}}
hal_data["_embedded"]["properties"].append(record_data)
# Print the HAL data
with open('json_format.json', 'w') as f:
json.dump(hal_data, f, indent=4, separators=(',', ': '))
I have exported a json file from queries to the REDCAP eLwazi Catalogue MetaData Management Project.
This contains the json output of the metadata for one field.
I also have an API key for querying the API directly. Reach out to me for it.
Editing the json schema from REDCAP to make it look like the json schema example here from data-catalogue-backend: