Title: | Wraps 'CCM' with Utility Functions |
---|---|
Description: | Provides a set of functions to perform queries against the 'CCM' API <https://mohcontacttracing.my.salesforce.com>. |
Authors: | James Lane [aut, cre] |
Maintainer: | James Lane <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-12 06:27:30 UTC |
Source: | https://github.com/durhamregionharp/ccmreportr |
getAttribute()
queries CCM for details about
a record. the parameter optionsList
specifies the
columns to return.
getAttribute(Id, optionsList)
getAttribute(Id, optionsList)
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. |
If the query succeeds, a tibble
containing data
for the specified Id
. Otherwise, a tibble
of
NA
values.
getCaseAttribute()
specifies the object used to
get related information about a case. This function
wraps getAttribute()
to allow iteration over multiple
cases. See getAttribute()
.
getCaseAttribute(attribute, case)
getCaseAttribute(attribute, case)
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. |
a tibble
of information related to a case.
getAttribute()
for information on how the CCM
query is executed. getCases()
for obtaining Case Id's
required for this function.
getCases()
returns a tibble
of data from the CCM Case object.
The Case object maps to Investigations on the client-side.
getCases( confirmedOnly = FALSE, from = "1990-01-01", to = as.character(Sys.time()), columns = "Id", healthUnit = NULL )
getCases( confirmedOnly = FALSE, from = "1990-01-01", to = as.character(Sys.time()), columns = "Id", healthUnit = NULL )
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. |
If the query succeeds, a tibble
containing columns
.
## 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)
## 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)
getDBLabels()
retrieves the description of a specified
object in CCM then searches for field names using the
field label seen on the client-side.
getDBLabels(table, colNames)
getDBLabels(table, colNames)
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 |
Character vector. Field names suitable for use in
subsequent SOQL queries. Elements form colNames
not found
in table
are removed from the results.
getExposureAttribute()
specifies the object used to
get related information about an exposure. This function
wraps getAttribute()
to allow iteration over multiple
exposures. See getAttribute()
.
getExposureAttribute(attribute, exposure)
getExposureAttribute(attribute, exposure)
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. |
a tibble
of information related to an exposure.
getAttribute()
for information on how the CCM
query is executed. getExposures()
for obtaining Exposure Id's
required for this function.
getExposures()
returns a user-defined data from the CCM Exposure object.
The Exposure object maps to Exposures on the client-side.
getExposures( type = NULL, from = "1990-01-01", to = as.character(Sys.time()), columns = "Id", healthUnit = NULL )
getExposures( type = NULL, from = "1990-01-01", to = as.character(Sys.time()), columns = "Id", healthUnit = NULL )
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. |
If the query succeeds, a tibble
containing columns
.
## 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)
## 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)
getHealthUnitByName()
searches the PHU_Stage_Table__c object
and returns the Id for the specified health unit.
getHealthUnitByName(healthUnitName)
getHealthUnitByName(healthUnitName)
healthUnitName |
Character scalar or vector. Names the health unit to use when searching for an Id. |
If the query succeeds, a character scalar or vector of health unit Id's. Otherwise, an error is returned.
getOutbreakAttribute()
specifies the object used to
get related information about an outbreak. This function
wraps getAttribute()
to allow iteration over multiple
outbreaks.
getOutbreakAttribute(attribute, outbreak)
getOutbreakAttribute(attribute, outbreak)
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. |
A tibble
of information related to an Outbreak.
getAttribute()
for information on how the CCM
query is executed. getOutbreaks()
for obtaining Outbreak Ids
required for this function.
getOutbreaks()
returns user-defined data from the CCM Outbreak object.
The Outbreak object maps to Outbreaks on the client-side.
getOutbreaks( confirmedOnly = TRUE, openOnly = TRUE, healthUnit = NULL, from = "1990-01-01", to = as.character(Sys.Date()), columns = "Id" )
getOutbreaks( confirmedOnly = TRUE, openOnly = TRUE, healthUnit = NULL, from = "1990-01-01", to = as.character(Sys.Date()), columns = "Id" )
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 |
If the query succeeds, a tibble
containing columns
.
## 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)
## 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)
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.
login()
login()
CCM access token for use in authorizing subsequent requests.
makeTimestame()
generates ISO-8601 formatted
date strings in UTC. This is the format required
to query datetime fields in CCM.
makeTimestamp(dateString)
makeTimestamp(dateString)
dateString |
Character scalar. Names the date which the function will use to create the formatted datetime. |
Character scalar. An ISO-8601 formatted date in the UTC timezone suitable for use in CCM queries.