R/result.ID.R

#' @author Gregoire Versmee, Laura Versmee

result.ID <- function(env, body, token, verbose = FALSE) {

  if (verbose)  message('\nGetting a result ID')

  ID <- httr::content(httr::POST(paste0(env, "/rest/v1/queryService/runQuery"), body = body))$resultId

  if (is.null(ID))  {
    body <- gsub("ENCOUNTER", "ENOUNTER", body)
    ID <- httr::content(httr::POST(paste0(env, "/rest/v1/queryService/runQuery"), body = body))$resultId
    if (!is.null(ID))  message(paste("!!!!! PLease, ask the developpers to fix the ENOUNTER issue on", env, "!!!!!"))
    else stop("\nInvalid query, process stopped", call. = FALSE)
  }

  if (verbose)  message(paste0("  -> Query #", ID))
  return(ID)
}
gversmee/picsuRe documentation built on May 24, 2019, 9:50 a.m.