fhirClient: fhirClient

Description Usage Arguments Details Examples

Description

Read and search only client in R for FHIR STU 3 and R4. Based on the official HL7 FHIR .NET API.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
client <- fhirClient$new(endpoint, token = NULL)

client$read(location, summaryType = NULL, returnType = "parsed")
client$search(resourceType, criteria = NULL, includes = NULL, pageSize = NULL, summaryType = NULL, returnType = "parsed")
client$searchById(resourceType, id, includes = NULL, summaryType = NULL, returnType = "parsed")
client$wholeSystemSearch(criteria = NULL, includes = NULL, pageSize = NULL, summaryType = NULL, returnType = "parsed")
client$searchParams(params, resourceType = NULL, returnType = "parsed")
client$continue(bundle)


client$setToken(token)

client$endpoint
client$authUrl
client$tokenUrl
client$registerUrl
client$token

print(client)

Arguments

client

A fhirClient object.

endpoint

The URL of the server to connect to.

token

An ouath 2.0 Token (httr Token 2.0)

resourceType

The type of resource to search for.

id

The id of the Resource to search for.

summaryType

Whether to include only return a summary of the Resource(s).

location

The url of the Resource to fetch. This can be a Resource id url or a version-specific.

criteria

The search parameters to filter the Resources on. Each given string is a combined key/value pair (separated by '=').

includes

Paths to include in the search.

pageSize

Asks server to limit the number of entries per page returned.

query

A searchParams object containing the search parameters.

bundle

The bundle as received from the last response.

returnType

Specify the return type. This can be "parsed", "json" or "xml".

Details

$new() Creates a new fhirClient using a given endpoint. If the endpoint does not end with a slash (/), it will be added.

$read() Fetches a typed Resource from a FHIR resource endpoint.

$search() Search for Resources of a certain type that match the given criteria.

$searchById() Search for Resources based on a Resource's id.

$wholeSystemSearch() Search for Resources across the whole server that match the given criteria.

$searchByQuery() Search for Resources based on a searchParams object.

$continue() Uses the FHIR paging mechanism to go navigate around a series of paged result Bundles.

$setToken() Saves an Oauth 2.0 token in a variable.

$endpoint Returns the endpoint.

$authUrl Returns the authorization server<e2><80><99>s OAuth authorization endpoint.

$tokenUrl Returns the authorization server<e2><80><99>s OAuth token endpoint.

$registerUrl Returns the endpoint where the client can register.

$token Returns the initialized token.

print(p) or p$print() Shows which endpoint is configured.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
## Not run: 
# Setting up a fhirClient
client <- fhirClient$new("https://vonk.fire.ly")
# Read
client$read("Patient/example")

# Search
bundle <- client$search("Patient", c("name=Peter", "address-postalcode=3999"))

while(!is.null(bundle)){
   # Do something useful
   bundle <- client$continue(bundle)
}

## End(Not run)
## Not run: 
# Using Oauth 2.0
client <- fhirClient$new("https://vonk.fire.ly")

# Retrieving a token

client_id <- "id"
client_secret <- "secret"
app_name <- "TestApp"
scopes <- c("patient/*.read")

app <- httr::oauth_app(appname = app_name, client_id, client_secret)
oauth_endpoint <- httr::oauth_endpoint(
                  authorize = paste(client$authUrl, "?aud=", client$endpoint, sep=""),
                  access = client$tokenUrl)
  
token <- httr::oauth2.0_token(endpoint = oauth_endpoint, app = app, scope = scopes)

# Set a token and read a patient resource
client$setToken(token$credentials$access_token)

client$read("Patient/example")

# Token refresh
token <- token$refresh()

client$setToken(token$credentials$access_token)


## End(Not run)

RonFHIR documentation built on Jan. 11, 2020, 9:36 a.m.