diff --git a/NAMESPACE b/NAMESPACE index 3e3c064..d7112ba 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -24,6 +24,7 @@ export(is.drugs) export(is.laboratory) export(is.physiology) export(lenstay) +export(long2stname) export(lookup.items) export(new.episode) export(physio.distribution) diff --git a/R/stdid.R b/R/stdid.R index 264519f..81135f5 100644 --- a/R/stdid.R +++ b/R/stdid.R @@ -86,6 +86,18 @@ stname2longname <- function(stname) { return(code) } +#' Convert long names to short names. +#' +#' @param l long name such as "heart rate" +#' @return short name character such as "h_rate" +#' @export +long2stname <- function(l) { + l <- as.character(l) + s <- long2stname.dict[l] + s[is.na(s)] <- l[is.na(s)] + return(s) +} + #' Identify the classification - classification1 #' diff --git a/R/zzz.R b/R/zzz.R index 34138d4..45ae7dd 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -34,6 +34,7 @@ longnames <- vapply(ITEM_REF, function(x) x$dataItem, "") stname2longname.dict <- longnames names(stname2longname.dict) <- stname + long2stname.dict <- reverse.name.value(stname2longname.dict) # classification dictionary: demographic, nurse, physiology, laboratory, drugs class.dict_code <- vapply(ITEM_REF, function(x) x$Classification1, "") @@ -50,6 +51,7 @@ assign("code2stname.dict" , code2stname.dict , envir=env) assign("stname2code.dict" , stname2code.dict , envir=env) assign("stname2longname.dict" , stname2longname.dict , envir=env) + assign("long2stname.dict" , long2stname.dict , envir=env) assign("class.dict_code" , class.dict_code , envir=env) assign("class.dict_stname", class.dict_stname, envir=env) assign("tval.dict_code" , tval.dict_code , envir=env) diff --git a/man/long2stname.Rd b/man/long2stname.Rd new file mode 100644 index 0000000..8755cab --- /dev/null +++ b/man/long2stname.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/stdid.R +\name{long2stname} +\alias{long2stname} +\title{Convert long names to short names.} +\usage{ +long2stname(l) +} +\arguments{ +\item{l}{long name such as "heart rate"} +} +\value{ +short name character such as "h_rate" +} +\description{ +Convert long names to short names. +} +