# NOT RUN {
# Read your private key
privatekey <- openssl::read_key("PrivateKey.pem")
# Create your claim
claim <- jose::jwt_claim(iss = "ServiceURL",
sub = "ClientID",
aud = "TokenURL",
# expiration date as epoch (5 minutes)
exp = as.integer(as.POSIXct( Sys.time() + 300)),
# 'random' number
jti = charToRaw(as.character(runif(1, 0.5, 100000000000))))
# Sign your claim with your private key
jwt <- jose::jwt_encode_sig(claim, privatekey)
# Define your scope(s)
scopes <- c("system/*.read", "system/CommunicationRequest.write")
# Create a new fhirBulkClient
bulkclient <- fhirBulkClient$new("FHIRBulkServerURL", tokenURL = "TokenURL")
# Retrieve your token
token <- bulkclient$retrieveToken(jwt, scopes)
# Set your token
bulkclient$setToken(token$access_token)
# Request a download for Patient Cohort 3
bulkclient$groupExport(3)
# Request the progress of the requests
bulkclient$getBulkStatus()
# When the downloads a available, download the bulkdata
patient_cohort_3 <- bulkclient$downloadBulk(1)
View(patient_cohort_3)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab