Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add REDCap methods, read data parameter from Dict or file #31

Merged
merged 28 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e60f493
Add repeating instrument methods
AshlinHarris Aug 21, 2024
d515024
Add file methods
AshlinHarris Aug 21, 2024
feae17a
Add REDCap_action type
AshlinHarris Aug 21, 2024
93199cd
Add report method
AshlinHarris Aug 21, 2024
a113aa6
Update arm methods
AshlinHarris Aug 21, 2024
705bc09
Update survey methods
AshlinHarris Aug 21, 2024
a99e409
Add DAG methods
AshlinHarris Aug 21, 2024
6b76974
Update event methods
AshlinHarris Aug 22, 2024
6f61c05
Log HTTP status code
AshlinHarris Aug 22, 2024
a3d4367
Assert url format
AshlinHarris Aug 23, 2024
414787c
Move HTTP status logs to debug
AshlinHarris Aug 23, 2024
3dab2fc
Update instrument methods
AshlinHarris Aug 23, 2024
658f46d
Update filerepository methods
AshlinHarris Aug 24, 2024
8fb2cc0
Add REDCap_data type (currently unused)
AshlinHarris Aug 24, 2024
9f9526d
Add test
AshlinHarris Aug 24, 2024
4972aae
Accept Dict or filename for data parameter
AshlinHarris Aug 24, 2024
0c02bb5
Add type assertion
AshlinHarris Aug 24, 2024
adbfd1b
Test types for project data import
AshlinHarris Aug 24, 2024
b01ecef
Timestamps can be String or DateTime
AshlinHarris Aug 24, 2024
c3e22f1
Add missing parameter
AshlinHarris Aug 24, 2024
cced65f
Support filename or Dict for data (for now, requires format=:json)
AshlinHarris Aug 24, 2024
f1d170f
Update types
AshlinHarris Aug 24, 2024
c499334
Clean up
AshlinHarris Aug 24, 2024
7f538b8
Add individual test files
AshlinHarris Aug 24, 2024
664da00
Convert Dict to CSV, JSON, or XML as needed
AshlinHarris Aug 24, 2024
fd0bc3d
Put post request (minus token) in debug message
AshlinHarris Aug 24, 2024
a072903
Clean up types
AshlinHarris Aug 24, 2024
154f251
Add TagBot.yml
AshlinHarris Aug 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/.github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: 3
permissions:
contents: write
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
ssh: ${{ secrets.DOCUMENTER_KEY }}
18 changes: 9 additions & 9 deletions src/REDCap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ using URIs

include("types.jl")
include("utils.jl")
#include("api_methods/arms.jl")
#include("api_methods/data_access_groups.jl")
#include("api_methods/events.jl")
include("api_methods/arms.jl")
include("api_methods/data_access_groups.jl")
include("api_methods/events.jl")
include("api_methods/field_names.jl")
#include("api_methods/files.jl")
#include("api_methods/file_repository.jl")
#include("api_methods/instruments.jl")
include("api_methods/files.jl")
include("api_methods/file_repository.jl")
include("api_methods/instruments.jl")
include("api_methods/logging.jl")
include("api_methods/metadata.jl")
include("api_methods/projects.jl")
include("api_methods/records.jl")
include("api_methods/redcap.jl")
#include("api_methods/repeating_instruments_and_events.jl")
#include("api_methods/reports.jl")
#include("api_methods/surveys.jl")
include("api_methods/repeating_instruments_and_events.jl")
include("api_methods/reports.jl")
include("api_methods/surveys.jl")
include("api_methods/users.jl")
include("api_methods/user_roles.jl")

Expand Down
44 changes: 35 additions & 9 deletions src/api_methods/arms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,56 @@ export delete_arms,
export_arms,
import_arms

function delete_arms(;arms=nothing)
function delete_arms(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
arms=nothing,
)

REDCap.request(;
content=REDCap_content(:arm),
action=:import,
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:arm),
action=REDCap_action(:import),
arms=arms,
)
end

function export_arms(;format=:xml,arms=nothing,returnFormat=nothing)
function export_arms(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
format::redcap_format_input=nothing,
returnFormat::redcap_returnFormat_input=nothing,
arms=nothing,
)

REDCap.request(;
content=REDCap_content(:arm),
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:arm),
format=REDCap_format(format),
arms=arms,
returnFormat=REDCap_format(returnFormat),
)
end

function import_arms(;format=:xml,data=nothing,override=0,returnFormat=nothing)
function import_arms(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
format::redcap_format_input=nothing,
data::redcap_data_input=nothing,
returnFormat::redcap_returnFormat_input=nothing,
override=0,
)

REDCap.request(;
content=REDCap_content(:arm),
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:arm),
override=override,
action=:import,
action=REDCap_action(:import),
format=REDCap_format(format),
data=data,
data=REDCap_data(data,REDCap_format(format)),
returnFormat=REDCap_format(returnFormat),
)
end
Expand Down
68 changes: 56 additions & 12 deletions src/api_methods/data_access_groups.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,96 @@ export delete_DAGs,
import_user_DAG_assignment,
switch_DAG

function delete_DAGs(;dags=nothing)
function delete_DAGs(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
dags=nothing)

REDCap.request(;
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:dag),
action=:delete,
action=REDCap_action(:delete),
dags=dags,
)
end

function export_DAGs(;format=:xml,returnFormat=nothing)
function export_DAGs(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
format::redcap_format_input=nothing,
#TODO: This is one of those ones that only take a format parameter
)

REDCap.request(;
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:dag),
format=REDCap_format(format),
returnFormat=REDCap_format(returnFormat),
)
end

function export_user_DAG_assignment(;format=:xml)
function export_user_DAG_assignment(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
format::redcap_format_input=nothing,
)

REDCap.request(;
content=REDCap_content(:userDagMapping),
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:userDagMapping),
format=REDCap_format(format),
)
end

function import_DAGs(;format=:xml,data=nothing,returnFormat=nothing)
function import_DAGs(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
data::redcap_data_input=nothing,
format::redcap_format_input=nothing,
returnFormat::redcap_returnFormat_input=nothing,
)

REDCap.request(;
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:dag),
action=:import,
action=REDCap_action(:import),
format=REDCap_format(format),
data=data,
data=REDCap_data(data,REDCap_format(format)),
returnFormat=REDCap_format(returnFormat),
)
end

function import_user_DAG_assignment(;format=:xml,data=nothing,returnFormat=nothing)
function import_user_DAG_assignment(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
data::redcap_data_input=nothing,
format::redcap_format_input=nothing,
returnFormat::redcap_returnFormat_input=nothing,
)

REDCap.request(;
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:userDagMapping),
format=REDCap_format(format),
data=data,
data=REDCap_data(data,REDCap_format(format)),
returnFormat=REDCap_format(returnFormat),
)
end

function switch_DAG(;dag=nothing)
function switch_DAG(;
data::redcap_data_input=nothing,
url::redcap_url_input=get_url(),
dag=nothing)
REDCap.request(;
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:dag),
action=:switch,
action=REDCap_action(:switch),
dag=dag,
)
end
Expand Down
46 changes: 36 additions & 10 deletions src/api_methods/events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,57 @@ export delete_events,
import_events,
export_events

function delete_events(;events=nothing)
function delete_events(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
events=nothing,
)

REDCap.request(;
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:event),
action=:import,
action=REDCap_action(:import),
events=events,
)
end

function export_events(;format=:xml,arms=nothing,returnFormat=nothing)
function export_events(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
format::redcap_format_input=nothing,
returnFormat::redcap_returnFormat_input=nothing,
arms=nothing,
)

REDCap.request(;
content=REDCap_content(:event),
url=REDCap_url(url),
token=REDCap_token(token),
format=REDCap_format(format),
arms=arms,
returnFormat=REDCap_format(returnFormat),
content=REDCap_content(:event),
arms=arms,
)
end

function import_events(;format=:xml,data=nothing,override=0,returnFormat=nothing)
function import_events(;
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
format::redcap_format_input=nothing,
returnFormat::redcap_returnFormat_input=nothing,
data=nothing,
override=0,
)

REDCap.request(;
content=REDCap_content(:event),
action=:import,
override=override,
url=REDCap_url(url),
token=REDCap_token(token),
format=REDCap_format(format),
data=data,
returnFormat=REDCap_format(returnFormat),
content=REDCap_content(:event),
action=REDCap_action(:import),
override=override,
data=REDCap_data(data,REDCap_format(format)),
)
end

10 changes: 5 additions & 5 deletions src/api_methods/field_names.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export export_list_of_export_field_names

function export_list_of_export_field_names(;
url::redcap_url_parameter=get_url(),
token::redcap_token_parameter=get_token(),
format::redcap_format_parameter=nothing,
returnFormat::redcap_returnFormat_parameter=nothing,
url::redcap_url_input=get_url(),
token::redcap_token_input=get_token(),
format::redcap_format_input=nothing,
returnFormat::redcap_returnFormat_input=nothing,
field=nothing
)

REDCap.request(;
url=URI(url),
url=REDCap_url(url),
token=REDCap_token(token),
content=REDCap_content(:exportFieldNames),
format=REDCap_format(format),
Expand Down
Loading