SkillAgentSearch skills...

CastoRedc

R wrapper to Castor EDC API

Install / Use

/learn @castoredc/CastoRedc
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

<!-- README.md is generated from README.Rmd. Please edit that file -->

Castor API R Package

The intent of this package is to provide convenient access to study data in Castor via R.

Package Structure

Access to data in the API comes in three forms:

  1. Access to individual items (getStudyDataPoint, getStudy, getRecord, etc.)
  2. Access to pages of items in a list (getStudyDataPoints, getStudies, getRecords, etc.)
  3. Processed into a data frame for straightforward analysis (getStudyData)

Installation

# install.packages("remotes")
remotes::install_github("castoredc/castoRedc")

Missing data

In the package, user missing data is handled in the following way. For date variables, they are represented by 31-12-29XX, where XX (95-99) indicates the type of missing data. For numeric variables, they are represented by the values -99 to -95, where 95 to 99 represent the type of missing data in Castor. For non-numeric variables, they are represented by ##_USER_MISSING_XX## where XX (95-99) indicates the type of missing data.

Testing

If you want to test the package, for example when developing, please fill in create_testing_credentials.R.
You should supply an example for each of the study, report, etc. Please make sure that the record has a value in the field. And that the report step is a child of the report.

Usage

See https://helpdesk.castoredc.com/article/124-application-programming-interface-api about generating your credentials.

Note: It is recommended that you read https://cran.r-project.org/web/packages/httr/vignettes/secrets.html about managing your credentials.

library(castoRedc)

castor_api <- CastorData$new(key = credentials$client_id, 
                             secret = credentials$client_secret, 
                             base_url = "https://data.castoredc.com")
studies <- castor_api$getStudies()

| crf_id | study_id | name | created_by | created_on | trial_registry_id | live | randomization_enabled | gcp_enabled | surveys_enabled | premium_support_enabled | main_contact | expected_centers | expected_records | slug | version | duration | domain | _links.self.href | |:-------------------------------------|:-------------------------------------|:-----------------------------------|:-------------------------------------|:--------------------|:------------------|:-----|:----------------------|:------------|:----------------|:------------------------|:-------------------------------------|-----------------:|-----------------:|:-----------------------|:--------|---------:|:-----------------------------|:----------------------------------------------------------------------------| | 15E88A04-9CB8-4B30-9A3C-B1DBFC96CD88 | 15E88A04-9CB8-4B30-9A3C-B1DBFC96CD88 | PythonWrapperTest - Study | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 2021-06-22 07:50:12 | | TRUE | FALSE | TRUE | TRUE | FALSE | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 1 | 180 | ESXnzDc2zuKJ7fFjEnUCu5 | 0.21 | 12 | https://data.castoredc.com | https://data.castoredc.com/api/study/15E88A04-9CB8-4B30-9A3C-B1DBFC96CD88 | | 1BCD52D3-7AB3-4EA9-8ABE-74B4B7087001 | 1BCD52D3-7AB3-4EA9-8ABE-74B4B7087001 | PythonWrapperTest - Client (Write) | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 2022-06-28 07:13:41 | | TRUE | TRUE | TRUE | TRUE | FALSE | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 1 | 100 | 8pDFJAdy4m3Kf8fZEMRxw6 | 0.01 | 24 | https://data.castoredc.com | https://data.castoredc.com/api/study/1BCD52D3-7AB3-4EA9-8ABE-74B4B7087001 | | C6073904-2B46-4F38-B359-A455FC255920 | C6073904-2B46-4F38-B359-A455FC255920 | PythonWrapperTest - Import | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 2021-03-12 12:47:30 | | TRUE | FALSE | FALSE | TRUE | FALSE | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 1 | 50 | ThTvYFAxJFodP35aATLKFd | 0.21 | 27 | https://data.castoredc.com | https://data.castoredc.com/api/study/C6073904-2B46-4F38-B359-A455FC255920 | | D234215B-D956-482D-BF17-71F2BB12A2FD | D234215B-D956-482D-BF17-71F2BB12A2FD | PythonWrapperTest - Client | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 2019-09-23 08:12:48 | | TRUE | TRUE | TRUE | TRUE | FALSE | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 2 | 50 | python-wrapper | 0.61 | 15 | https://data.castoredc.com | https://data.castoredc.com/api/study/D234215B-D956-482D-BF17-71F2BB12A2FD | | D82A17DE-E280-4D69-B96A-4399872BBECC | D82A17DE-E280-4D69-B96A-4399872BBECC | PythonWrapperTest - SpecialCases | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 2022-01-03 13:52:27 | | TRUE | FALSE | TRUE | TRUE | FALSE | B23ABCC4-3A53-FB32-7B78-3960CC907F25 | 1 | 500 | p8CPbd2rnbBFkb2oW5GFUg | 1.11 | 60 | https://data.castoredc.com | https://data.castoredc.com/api/study/D82A17DE-E280-4D69-B96A-4399872BBECC |

(example_study_id <- studies[["study_id"]][1])
#> [1] "15E88A04-9CB8-4B30-9A3C-B1DBFC96CD88"
study <- castor_api$getStudyData(example_study_id)
<table class="kable_wrapper"> <tbody> <tr> <td>

| Participant_ID | Site_Abbreviation | Randomization_Group | Participant_Creation | ic_date | ic_versions#Other | ic_versions#Main study CF | ic_main_version | ic_language#English | ic_language#Dutch | |:---------------|:------------------|:--------------------|:---------------------|:-----------|:------------------|:--------------------------|:----------------|:--------------------|:------------------| | 110001 | FGV | NA | 2021-06-22 09:51:49 | 2021-06-22 | FALSE | TRUE | 2.5 | FALSE | FALSE | | 110002 | FGV | NA | 2021-06-22 09:59:01 | NA | FALSE | FALSE | NA | FALSE | FALSE |

</td> <td> <table class="kable_wrapper"> <tbody> <tr> <td>

| repeating_data_name | created_on | Participant_ID | repeating_data_inst_name | AE_type | AE_SAE | AE_severity | AE_stopdate | AE_expected | AE_outcome | AE_action | AE_relation | AE_startdate | |:--------------------|:--------------------|:---------------|:------------------------------------|:-----------------|:-------|:-----------------|:------------|:------------|:-----------|:---------------------|:-------------------|:-------------| | Adverse event | 2021-06-22 09:55:13 | 110001 | Adverse event - 22-06-2021 09:55:12 | A bug in the API | Yes | Life-threatening | 24-06-2021 | Yes | Resolved | Medical intervention | Definitely related | 23-06-2021 | | Adverse event | 2021-06-22 09:58:13 | 110001 | Adverse event - 22-06-2021 09:58:12 | NA | NA | NA | NA | NA | NA | NA | NA | NA |

</td> <td>

| repeating_data_name | created_on | Participant_ID | repeating_data_inst_name | comorbidities | |:--------------------|:--------------------|:---------------|:------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | Comorbidities | 2021-06-22 09:56:07 | 110001 | Comorbidities - 22-06-2021 09:56:06 | {“file_name”:“Y29tb3JiaWRpdGllcy50eHQ=”,“mime_type”:“text/plain”,“file_size”:48,“storage_path”:“B2CF4AB1-CCCF-43CD-9933-13DE879C1AB5”,“key”:{“generation”:{“metadata”:[],“version”:[“rb”,1]},“storage”:{“metadata”:{“ciphertext”:“CiQAsmjNQAKXE4sQbDJagktdyNPH7fbo6bCMPRGYrSp/hYls7U0SSQAAsqYVDFxH1mKbO5tgQ3RmzxhkmAvUKA7LDzwqaU1gcdWuKvplMjniW1OjZwW8qntb+a60NG12EN9k6YSifTl6749JXjB/4Fw=”,“key_version”:“1”,“project”:“castoredc-kms”,“location”:“europe-west4”,“keyring”:“15E88A04-9CB8-4B30-9A3C-B1DBFC96CD88”,“keyname”:“41B6FFD8-61BB-4D06-B5B1-58D8D2875C68”},“version”:[“google”,1]}},“algorithm”:{“version”:[“sodium”,1],“attributes”:{“nonce”:“0021a3e7a6

Related Skills

View on GitHub
GitHub Stars6
CategoryDevelopment
Updated9mo ago
Forks8

Languages

R

Security Score

77/100

Audited on Jun 29, 2025

No findings