Title: | Wraps 'CCM' with Utility Functions |
Version: | 0.1.0 |
Description: | Provides a set of functions to perform queries against the 'CCM' API https://mohcontacttracing.my.salesforce.com. |
BugReports: | https://github.com/DurhamRegionHARP/ccmReportR/issues |
License: | MIT + file LICENSE |
URL: | https://github.com/DurhamRegionHARP/ccmReportR |
Encoding: | UTF-8 |
LazyData: | true |
RoxygenNote: | 7.1.1 |
Imports: | dplyr (≥ 1.0.2), httr (≥ 1.4.2), jsonlite (≥ 1.7.1), keyring (≥ 1.1.0), lubridate (≥ 1.7.9), purrr (≥ 0.3.4), tibble (≥ 3.0.5), rlang |
NeedsCompilation: | no |
Packaged: | 2021-02-11 19:07:47 UTC; lane_j |
Author: | James Lane [aut, cre] |
Maintainer: | James Lane <lanejames35@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2021-02-11 20:10:02 UTC |
Get data from CCM for a specified record
Description
getAttribute()
queries CCM for details about
a record. the parameter optionsList
specifies the
columns to return.
Usage
getAttribute(Id, optionsList)
Arguments
Id |
Character scalar. Names the record to obtain information about. |
optionsList |
list object. Controls the behaviour of the query including the filter for the query, and data to return. |
Value
If the query succeeds, a tibble
containing data
for the specified Id
. Otherwise, a tibble
of
NA
values.
Get attributes related to a case
Description
getCaseAttribute()
specifies the object used to
get related information about a case. This function
wraps getAttribute()
to allow iteration over multiple
cases. See getAttribute()
.
Usage
getCaseAttribute(attribute, case)
Arguments
attribute |
Character scalar. Names the CCM object to obtain related information about a case. One of the currently supported objects:
|
case |
Character scalar or vector. Names the CCM Case Id to use when obtaining information. |
Value
a tibble
of information related to a case.
See Also
getAttribute()
for information on how the CCM
query is executed. getCases()
for obtaining Case Id's
required for this function.
Execute a SOQL query against the Case object
Description
getCases()
returns a tibble
of data from the CCM Case object.
The Case object maps to Investigations on the client-side.
Usage
getCases(
confirmedOnly = FALSE,
from = "1990-01-01",
to = as.character(Sys.time()),
columns = "Id",
healthUnit = NULL
)
Arguments
confirmedOnly |
Logical scalar. Should the query limit results to confirmed cases? Returns confirmed and probable cases by default. |
from |
Character scalar. Identifies the start of the date range to include in the query. Defaults to the origin date of CCM. |
to |
Character scalar. Identifies the end of the date range
to include in the query. Defaults to |
columns |
Character scalar or character vector. Names the columns to
return from the Case object. Defaults to |
healthUnit |
Character vector or scalar. Names the Public Health Unit
used to filter the query. |
Value
If the query succeeds, a tibble
containing columns
.
Examples
## Not run:
Get all confirmed cases for Durham Region
cases <- getCases(
confirmedOnly = TRUE,
healthUnit = 'Durham Region Health Department'
)
Specify the data to return. This can be field names or labels
N.B. Names are case sensitive!
cases <- getCases(
columns = c("Id", "Reported Date", "Episode Date", "CCM_Episode_Date_Type__c")
)
Limit the data to a specific time period.
cases <- getCases(
from = "2020-10-12",
to = "2020-10-17"
)
## End(Not run)
Helper function for building SOQL queries
Description
getDBLabels()
retrieves the description of a specified
object in CCM then searches for field names using the
field label seen on the client-side.
Usage
getDBLabels(table, colNames)
Arguments
table |
Character scalar. Names the CCM object which the function will use to search for field names. |
colNames |
Character vector. Contains a combination
field names and labels to search for in |
Value
Character vector. Field names suitable for use in
subsequent SOQL queries. Elements form colNames
not found
in table
are removed from the results.
Get attributes related to an exposure
Description
getExposureAttribute()
specifies the object used to
get related information about an exposure. This function
wraps getAttribute()
to allow iteration over multiple
exposures. See getAttribute()
.
Usage
getExposureAttribute(attribute, exposure)
Arguments
attribute |
character scalar. Names the CCM object used to obtain information about an exposure. One of the currently supported objects:
|
exposure |
character scalar or vector. Names the CCM Exposure Id to obtain information about. |
Value
a tibble
of information related to an exposure.
See Also
getAttribute()
for information on how the CCM
query is executed. getExposures()
for obtaining Exposure Id's
required for this function.
Execute a SOQL query against the Exposure object
Description
getExposures()
returns a user-defined data from the CCM Exposure object.
The Exposure object maps to Exposures on the client-side.
Usage
getExposures(
type = NULL,
from = "1990-01-01",
to = as.character(Sys.time()),
columns = "Id",
healthUnit = NULL
)
Arguments
type |
Character vector or scalar. Names the exposure type used to filter the query. Defaults to all exposure types. One or more of:
|
from |
Character scalar. Identifies the start of the date range to include in the query. Defaults to the origin date of CCM. |
to |
Character scalar. Identifies the end of the date range
to include in the query. Defaults to |
columns |
Character scalar or character vector. Names the columns to
return from the exposure object. Defaults to |
healthUnit |
Character vector or scalar. Names the Public Health Unit
used to filter the query. |
Value
If the query succeeds, a tibble
containing columns
.
Examples
## Not run:
Get all community exposures for Durham Region
exposures <- getExposures(
type = 'Community',
healthUnit = 'Durham Region Health Department'
)
Specify the data to return. This can be field names or labels
N.B. Names are case sensitive!
exposures <- getExposures(
columns = c("Id", "Exposure Name", "CCM_Exposure_Setting__c")
)
Limit the data to a specific time period.
exposures <- getExposures(
from = "2020-12-12",
to = "2020-12-17"
)
## End(Not run)
Retrieve a Health Unit's Id by name
Description
getHealthUnitByName()
searches the PHU_Stage_Table__c object
and returns the Id for the specified health unit.
Usage
getHealthUnitByName(healthUnitName)
Arguments
healthUnitName |
Character scalar or vector. Names the health unit to use when searching for an Id. |
Value
If the query succeeds, a character scalar or vector of health unit Id's. Otherwise, an error is returned.
Get attributes related to an outbreak
Description
getOutbreakAttribute()
specifies the object used to
get related information about an outbreak. This function
wraps getAttribute()
to allow iteration over multiple
outbreaks.
Usage
getOutbreakAttribute(attribute, outbreak)
Arguments
attribute |
Character scalar. Names the CCM object to obtain related information about a case. One of the currently supported objects:
|
outbreak |
Character scalar or vector. Names the Outbreak Id to use when obtaining information. |
Value
A tibble
of information related to an Outbreak.
See Also
getAttribute()
for information on how the CCM
query is executed. getOutbreaks()
for obtaining Outbreak Ids
required for this function.
Execute a SOQL query against the Outbreak object
Description
getOutbreaks()
returns user-defined data from the CCM Outbreak object.
The Outbreak object maps to Outbreaks on the client-side.
Usage
getOutbreaks(
confirmedOnly = TRUE,
openOnly = TRUE,
healthUnit = NULL,
from = "1990-01-01",
to = as.character(Sys.Date()),
columns = "Id"
)
Arguments
confirmedOnly |
Logical scalar. Should the query limit results to confirmed outbreaks? Returns confirmed and suspect outbreaks by default. |
openOnly |
Logical scalar. Should the query limit results to open outbreaks? Returns open and closed outbreaks by default. |
healthUnit |
Character vector or scalar. Names the Public Health Unit
used to filter the query. |
from |
Character scalar. Identifies the start of the date range to include in the query. Defaults to the origin date of CCM. |
to |
Character scalar. Identifies the end of the date range
to include in the query. Defaults to |
columns |
Character scalar or character vector. Names the columns to
return from the Outbreak object. Defaults to |
Value
If the query succeeds, a tibble
containing columns
.
Examples
## Not run:
Get all open outbreaks for Durham.
outbreaks <- getOutbreaks(
confirmedOnly = FALSE,
healthUnit = 'Durham Region Health Department'
)
Specify the data to return. This can be field names or labels
N.B. Names are case sensitive!
outbreaks <- getOutbreaks(
columns = c("Id", "Outbreak Name", "Outbreak Number")
)
Limit the data to a specific time period.
outbreaks <- getOutbreaks(
from = "2021-01-01",
to = "2020-01-17"
)
## End(Not run)
Obtain an access token to authorize requests
Description
This function implements the OAuth2.0 device grant flow see https://tools.ietf.org/html/rfc6749#section-1.3.1 and https://help.salesforce.com/articleView?id=remoteaccess_oauth_device_flow.htm&type=5 for more information. The token is stored in the OS keyring.
Usage
login()
Value
CCM access token for use in authorizing subsequent requests.
Helper function for building ISO-8601 dates
Description
makeTimestame()
generates ISO-8601 formatted
date strings in UTC. This is the format required
to query datetime fields in CCM.
Usage
makeTimestamp(dateString)
Arguments
dateString |
Character scalar. Names the date which the function will use to create the formatted datetime. |
Value
Character scalar. An ISO-8601 formatted date in the UTC timezone suitable for use in CCM queries.