last_events: Selects the earliest event grouped by patient

Description Usage Arguments Value Examples

Description

This function runs a select_events() query and then groups by patient id and picks only the latest event for each patient

Usage

1
2
last_events(db = NULL, tab, columns = "eventdate", where = NULL,
  sql_only = FALSE, group_column = "patid", date_column = "eventdate")

Arguments

db

A database connection object

tab

the database table to extract from

columns

The other columns to be extracted

where

sting representation of the selection criteria

sql_only

logical should the function just return a string of the SQL query?

group_column

column to group by. Default is patid

date_column

the column to sort by. default is eventdate

Value

a dataframe or a string representing an sql query

Examples

1
2
3
4
5
## Not run: 
b2 <- last_events(db, tab = "Clinical", other_columns = c("eventdate", "medcode"), 
where = "medcode %in% .(a$medcode)")

## End(Not run)

rEHR documentation built on Jan. 23, 2017, 1 p.m.

Related to last_events in rEHR...