R/patient.R

Defines functions getName BirthDate Patient

Documented in BirthDate getName Patient

#' Patient model
#' @export
setClass("Patient", contains = "Resource")

#' Patient class
#'
#' @param jsonDict A list of items for the Patient resource.
#' @return A object of Patient
#' @export
#' @examples
#' Patient(list(id = "pt1"))
Patient <- function(jsonDict = list()){
    pt <- .fhirclient()$models$patient$Patient(jsonDict)
    new("Patient", py = pt)
}

## #' @importFrom S4Vectors SimpleList
## setMethod(show, "Patient", function(object){
##     cat(as.character(object@py$"__class__"), "\n")
##     show(SimpleList(object@py$as_json()))
## })

#' Birth Date
#'
#' @param pt A `Resource` object from `Read`.
#' @importFrom methods is new
#' @export
BirthDate <- function(pt){
    stopifnot(is(pt, "Resource"))
    pt$birthDate$isostring
}

#' getName
#'
#' @param pt Extract full name
#' @export
getName <- function(pt){
    stopifnot(is(pt, "Resource"))
    ct <- Client(api_base = "example.com")
    lapply(pt$name, function(x)ct$human_name(x))
}
qhu75/fhiRclient documentation built on Dec. 31, 2020, 2:11 a.m.