jackwasey / icd
Showing 36 of 126 files from the diff.
Other files ignored by Codecov
R/zzz.R has changed.
R/askYesNo.R was deleted.
src/ranges.hpp has changed.
.gitignore has changed.
src/Makevars.win has changed.
tools/tidy.sh has changed.
src/refactor.hpp has changed.
NAMESPACE has changed.
src/test-cpp.cpp has changed.
.Rbuildignore has changed.
src/Makevars.in has changed.
src/convert.hpp has changed.
tools/rhub.r has changed.
src/attr.hpp has changed.
src/is.hpp has changed.
R/RcppExports.R has changed.
src/manip.h was deleted.
configure has changed.
src/local.hpp has changed.
src/util.hpp has changed.
README.md has changed.
src/convert10.h was deleted.
configure.ac has changed.
NEWS.md has changed.
src/icd_types.hpp has changed.
codemeta.json has changed.
tools/publish.sh has changed.
src/sort.hpp has changed.
src/.gitignore has changed.
DESCRIPTION has changed.
R/icd-package.R has changed.

@@ -168,10 +168,21 @@
Loading
168 168
#' @keywords internal
169 169
#' @noRd
170 170
icd_classes_conflict <- function(x) {
171 -
  is.icd9(x) && is.icd10(x) ||
172 -
    is.icd9cm(x) && is.icd9cm_pc(x) ||
173 -
    is.icd10cm(x) && is.icd10cm_pc(x) ||
174 -
    is.icd_long_data(x) && is.icd_wide_data(x)
171 +
  if (is.icd9(x) && is.icd10(x)) {
172 +
    return(TRUE)
173 +
  }
174 +
175 +
  if (is.icd9cm(x) && is.icd9cm_pc(x)
176 +
  ) {
177 +
    return(TRUE)
178 +
  }
179 +
  if (is.icd10cm(x) && is.icd10cm_pc(x)) {
180 +
    return(TRUE)
181 +
  }
182 +
  if (is.icd_long_data(x) && is.icd_wide_data(x)) {
183 +
    return(TRUE)
184 +
  }
185 +
  return(FALSE)
175 186
}
176 187
177 188
#' Prefer an order of classes

@@ -1,4 +1,4 @@
Loading
1 -
#include "icd_types.h"
1 +
#include "icd_types.hpp"
2 2
#include <stdio.h> // for sprintf, size_t
3 3
#include <string>
4 4
#include <vector>
5 5
imilarity index 84%
6 6
ename from src/fastIntToString.h
7 7
ename to src/fastIntToString.hpp

@@ -1,8 +1,8 @@
Loading
1 -
#include "relevant.h"
2 -
#include "fastIntToString.h"
3 -
#include "icd_types.h"
4 -
#include "local.h"
5 -
#include "refactor.h"
1 +
#include "relevant.hpp"
2 +
#include "fastIntToString.hpp"
3 +
#include "icd_types.hpp"
4 +
#include "local.hpp"
5 +
#include "refactor.hpp"
6 6
#include <algorithm> // for binary_search, copy
7 7
#include <cstring>
8 8
#include <string>
@@ -15,7 +15,7 @@
Loading
15 15
  // over-reserve (and maybe expand), target is unique number
16 16
  allCodesSet.reserve(allCodesSet.size() + codes.size());
17 17
  DEBUG_VEC(codes);
18 -
  for (String c : codes) {
18 +
  for (const String& c : codes) {
19 19
    if (c != NA_STRING) { allCodesSet.insert(c.get_cstring()); }
20 20
  }
21 21
}
@@ -57,8 +57,8 @@
Loading
57 57
58 58
// do the finding
59 59
CV Relevant::findRelevant() {
60 -
  for (CV cmb : src_map) {
61 -
    for (String cmbCode : cmb) {
60 +
  for (const CV& cmb : src_map) {
61 +
    for (const String& cmbCode : cmb) {
62 62
      if (allCodesSet.find(cmbCode.get_cstring()) != allCodesSet.end()) {
63 63
        TRACE("Pushing back" << cmbCode.get_cstring());
64 64
        r.insert(((String)cmbCode).get_cstring());
@@ -91,7 +91,7 @@
Loading
91 91
  return wrap(r); // or keep as STL container?
92 92
}
93 93
94 -
RelMap Relevant::findRel(const CharacterVector x) {
94 +
RelMap Relevant::findRel(const CharacterVector& x) {
95 95
  RelMap out;
96 96
  DEBUG("building um using:");
97 97
  DEBUG_VEC(x);
98 98
imilarity index 86%
99 99
ename from src/relevant.h
100 100
ename to src/relevant.hpp

@@ -130,8 +130,9 @@
Loading
130 130
131 131
#' Expand two major codes to a range
132 132
#'
133 -
#' Expand a pair of major codes into a range of major codes. Primarily for use
134 -
#' by \code{icd.data}.
133 +
#' Expand a pair of major codes into a range of major codes.
134 +
#'
135 +
#' Primarily for internal use
135 136
#' @examples
136 137
#' expand_range_major("100", "102")
137 138
#' @template dotdotdot

@@ -113,11 +113,6 @@
Loading
113 113
  res
114 114
}
115 115
116 -
# simple backport
117 -
isFALSE <- function(x) {
118 -
  is.logical(x) && length(x) == 1L && !is.na(x) && !x
119 -
}
120 -
121 116
#' @rdname sort_icd
122 117
#' @export
123 118
order.icd9 <- function(x, na.last = TRUE) {

@@ -1,5 +1,5 @@
Loading
1 1
#include <Rcpp.h>
2 -
#include "sort.h"
2 +
#include "sort.hpp"
3 3
using namespace Rcpp;
4 4
5 5
IntegerVector orderWorker(
@@ -24,7 +24,7 @@
Loading
24 24
25 25
LogicalVector compareVectorWorker(const StringVector& x,
26 26
                                  const StringVector& y,
27 -
                                  std::function <bool (String, String)> f) {
27 +
                                  const std::function <bool (String, String)>& f) {
28 28
  if (x.size() != y.size()) stop("Both x and y must be same length");
29 29
  if (x.size() == 0) return LogicalVector(0);
30 30
  LogicalVector out(x.size());
@@ -43,7 +43,7 @@
Loading
43 43
}
44 44
45 45
// [[Rcpp::export(icd9_compare_rcpp)]]
46 -
bool icd9Compare(String a, String b) {
46 +
bool icd9Compare(const String& a, const String& b) {
47 47
  if (b == NA_STRING && a != NA_STRING) {
48 48
    // even if x is also NA, we still return true
49 49
    return true;
50 50
imilarity index 91%
51 51
ename from src/sort.h
52 52
ename to src/sort.hpp

@@ -24,7 +24,7 @@
Loading
24 24
  assert_int(n_comorbidities)
25 25
  assert_int(n_codes)
26 26
  get_n_or_len <- function(x, n) {
27 -
    x[1:ifelse(length(x) < n, length(x), n)]
27 +
    x[seq_len(ifelse(length(x) < n, length(x), n))]
28 28
  }
29 29
  message(
30 30
    "Showing first ",

@@ -1,5 +1,5 @@
Loading
1 -
#include "is.h"
2 -
#include "icd_types.h"
1 +
#include "is.hpp"
2 +
#include "icd_types.hpp"
3 3
#include <string>
4 4
#include <vector>
5 5
6 6
imilarity index 88%
7 7
ename from src/is.h
8 8
ename to src/is.hpp

@@ -24,14 +24,15 @@
Loading
24 24
#' @param var_name character name of variable or its symbol either of which
25 25
#'   would find \code{myvar} in the parent environment, and save it as
26 26
#'   \code{myvar.RData} in \code{package_root/data}.
27 -
#' @param compress gzip default because it is fastest to unzip
27 +
#' @param compress xz now default, as reasonably close to gzip speed for
28 +
#'   decompression and compression approaching twice as compact archives.
28 29
#' @param envir environment in which to look for the variable to save
29 30
#' @return invisibly returns the data
30 31
#' @keywords internal
31 32
#' @noRd
32 33
.save_in_data_dir <- function(var_name,
33 34
                              x = NULL,
34 -
                              compress = "gzip",
35 +
                              compress = "xz",
35 36
                              envir = parent.frame()) {
36 37
  if (!is.character(var_name)) {
37 38
    var_name <- as.character(substitute(var_name))

@@ -39,6 +39,8 @@
Loading
39 39
#' @noRd
40 40
.parse_icd9cm_rtf_year <- function(year = "2014",
41 41
                                   save_pkg_majors = FALSE) {
42 +
  code <- NULL
43 +
  three_digit <- NULL
42 44
  year <- as.character(year)
43 45
  stopifnot(year %in% .icd9cm_sources$f_year)
44 46
  f_info_rtf <- .dl_icd9cm_rtf_year(year)

@@ -1,5 +1,5 @@
Loading
1 -
#include "local.h"
2 -
#include "relevant.h"
1 +
#include "local.hpp"
2 +
#include "relevant.hpp"
3 3
using namespace Rcpp;
4 4
5 5
#ifndef MAPPLUS_H_
6 6
imilarity index 98%
7 7
ename from src/range-const.h
8 8
ename to src/range-const.hpp

@@ -1,5 +1,5 @@
Loading
1 -
#include "icd_types.h"
2 -
#include "is.h"      // for icd9IsASingleVE
1 +
#include "icd_types.hpp"
2 +
#include "is.hpp"      // for icd9IsASingleVE
3 3
#include <algorithm> // for fill
4 4
#include <iterator>  // for distance
5 5
#include <string.h>  // for strlen
@@ -93,6 +93,6 @@
Loading
93 93
}
94 94
95 95
// [[Rcpp::export]]
96 -
CV icd9MajMinToDecimal(const CV mjr, const CV mnr) {
96 +
CV icd9MajMinToDecimal(const CV& mjr, const CV& mnr) {
97 97
  return icd9MajMinToCode(mjr, mnr, false);
98 98
}
99 99
imilarity index 97%
100 100
ename from src/appendMinor.h
101 101
ename to src/appendMinor.hpp

@@ -1,6 +1,6 @@
Loading
1 -
#include "manip.h"
2 -
#include "convert.h"
3 -
#include "is.h"
1 +
#include "manip.hpp"
2 +
#include "convert.hpp"
3 +
#include "is.hpp"
4 4
#include <string.h> // for strlen
5 5
6 6
using namespace Rcpp;
@@ -9,7 +9,7 @@
Loading
9 9
//' @keywords internal manip
10 10
//' @noRd
11 11
// [[Rcpp::export]]
12 -
String icd9AddLeadingZeroesMajorSingle(String mjr) {
12 +
String icd9AddLeadingZeroesMajorSingle(const String& mjr) {
13 13
  if (mjr == NA_STRING) return (NA_STRING);
14 14
  std::string m(mjr);
15 15
  if (!icd9IsASingleVE(mjr.get_cstring())) {
@@ -97,7 +97,7 @@
Loading
97 97
}
98 98
99 99
// [[Rcpp::export(icd9_add_leading_zeroes_major)]]
100 -
CV icd9AddLeadingZeroesMajor(CV mjr) {
100 +
CV icd9AddLeadingZeroesMajor(const CV& mjr) {
101 101
  return sapply(mjr, icd9AddLeadingZeroesMajorSingle);
102 102
}
103 103
@@ -111,7 +111,7 @@
Loading
111 111
//' @keywords internal manip
112 112
//' @noRd
113 113
// [[Rcpp::export(icd9_add_leading_zeroes_rcpp)]]
114 -
CV icd9AddLeadingZeroes(CV x, bool short_code) {
114 +
CV icd9AddLeadingZeroes(const CV& x, bool short_code) {
115 115
  if (short_code) {
116 116
    // a shortcut for when short codes is just to add the appropriate leading
117 117
    // zeros when the total length is <3. Even then decimal may be quicker by

@@ -51,7 +51,7 @@
Loading
51 51
    stopifnot(length(x) == 1)
52 52
    x <- x[[1]]
53 53
  }
54 -
  y <- as_char_no_warn(x)[1:min(n, length(x))]
54 +
  y <- as_char_no_warn(x)[seq_len(min(n, length(x)))]
55 55
  if (!is.null(short_code)) {
56 56
    if (short_code) {
57 57
      i9 <- sum(is_valid.icd9(y, short_code = TRUE), na.rm = TRUE)
@@ -75,7 +75,7 @@
Loading
75 75
}
76 76
77 77
get_icd_defined_percent <- function(x, short_code = NULL, n = 100) {
78 -
  y <- as_char_no_warn(x)[1:min(n, length(x))]
78 +
  y <- as_char_no_warn(x)[seq_len(min(n, length(x)))]
79 79
  if (!is.null(short_code)) {
80 80
    if (short_code) {
81 81
      i9 <- sum(is_defined.icd9(y, short_code = TRUE), na.rm = TRUE)

@@ -1,4 +1,4 @@
Loading
1 -
#include "local.h" // for CV, VecStr
1 +
#include "local.hpp" // for CV, VecStr
2 2
#include <iterator>    // for advance
3 3
#include <vector>
4 4
using namespace Rcpp;

@@ -1,5 +1,5 @@
Loading
1 -
#include "refactor.h"
2 -
#include "local.h"
1 +
#include "refactor.hpp"
2 +
#include "local.hpp"
3 3
4 4
using namespace Rcpp;
5 5
6 6
imilarity index 97%
7 7
ename from src/refactor.h
8 8
ename to src/refactor.hpp

@@ -1,5 +1,5 @@
Loading
1 -
#include "util.h"
2 -
#include "local.h"
1 +
#include "util.hpp"
2 +
#include "local.hpp"
3 3
#include <algorithm> // for copy, sort, transform
4 4
#include <iterator>  // for back_insert_iterator
5 5
#include <math.h>    // for floor
@@ -8,6 +8,7 @@
Loading
8 8
#include <stdlib.h>
9 9
#include <string.h> // for strcmp
10 10
#include <string>
11 +
#include <utility>
11 12
#include <vector>
12 13
13 14
using namespace Rcpp;
@@ -35,7 +36,7 @@
Loading
35 36
  // according to
36 37
  // http://stackoverflow.com/questions/10789740/passing-stdstring-by-value-or-reference
37 38
  // C++11 will avoid copy even without using reference argument.
38 -
  return trimLeftCpp(trimRightCpp(s));
39 +
  return trimLeftCpp(trimRightCpp(std::move(s)));
39 40
}
40 41
41 42
// [[Rcpp::export]]
@@ -134,6 +135,6 @@
Loading
134 135
#ifdef _LIBCPP_VERSION
135 136
  Rcpp::Rcout << "libc++ from LLVM/clang)" << std::endl;
136 137
#endif
137 -
#include "makevars.h"
138 +
#include "makevars.hpp"
138 139
  Rcpp::Rcout << Makevars << std::endl;
139 140
}
140 141
imilarity index 95%
141 142
ename from src/util.h
142 143
ename to src/util.hpp

@@ -1,9 +1,9 @@
Loading
1 -
#include "ranges.h"
2 -
#include "appendMinor.h" // for icd9MajMinToShort, icd9Ma...
3 -
#include "convert.h"     // for icd9DecimalToShort, icd9S...
4 -
#include "icd_types.h"   // for CV, VecStr, Str
5 -
#include "is.h"          // for icd9IsASingleE
6 -
#include "local.h"       // for icd_set
1 +
#include "ranges.hpp"
2 +
#include "appendMinor.hpp" // for icd9MajMinToShort, icd9Ma...
3 +
#include "convert.hpp"     // for icd9DecimalToShort, icd9S...
4 +
#include "icd_types.hpp"   // for CV, VecStr, Str
5 +
#include "is.hpp"          // for icd9IsASingleE
6 +
#include "local.hpp"       // for icd_set
7 7
#include <algorithm>     // for set_intersection
8 8
#include <iterator>      // for insert_iterator, inserter
9 9
#include <set>           // for _Rb_tree_const_iterator, set
10 10
imilarity index 95%
11 11
ename from src/ranges.h
12 12
ename to src/ranges.hpp

@@ -1,12 +1,12 @@
Loading
1 -
#include "convert.h"
2 -
#include "icd_types.h"
1 +
#include "convert.hpp"
2 +
#include "icd_types.hpp"
3 3
extern "C" {
4 4
#include <cstddef> // for size_t
5 5
}
6 -
#include "appendMinor.h" // for icd9MajMinToCode
7 -
#include "is.h"          // for icd9IsASingleE, icd9IsAS...
8 -
#include "manip.h"       // for icd9AddLeadingZeroesMajor
9 -
#include "util.h"        // for strimCpp, trimLeftCpp
6 +
#include "appendMinor.hpp" // for icd9MajMinToCode
7 +
#include "is.hpp"          // for icd9IsASingleE, icd9IsAS...
8 +
#include "manip.hpp"       // for icd9AddLeadingZeroesMajor
9 +
#include "util.hpp"        // for strimCpp, trimLeftCpp
10 10
#include <string>        // for string
11 11
12 12
using namespace Rcpp;
@@ -38,7 +38,7 @@
Loading
38 38
}
39 39
40 40
// [[Rcpp::export]]
41 -
List icd9ShortToParts(const CV &icd9Short, String mnrEmpty) {
41 +
List icd9ShortToParts(const CV &icd9Short, const String& mnrEmpty) {
42 42
  CV mjr(icd9Short.size());
43 43
  CV mnr(icd9Short.size());
44 44
  for (int i = 0; i < icd9Short.size(); ++i) {
@@ -91,7 +91,7 @@
Loading
91 91
}
92 92
93 93
// [[Rcpp::export]]
94 -
List icd9DecimalToParts(const CV &icd9Decimal, const String mnrEmpty) {
94 +
List icd9DecimalToParts(const CV &icd9Decimal, const String& mnrEmpty) {
95 95
  CV mjrs;
96 96
  CV mnrs;
97 97
  int ilen = icd9Decimal.length();
@@ -114,7 +114,7 @@
Loading
114 114
    std::string thiscode = as<std::string>(*it);
115 115
    thiscode =
116 116
      strimCpp(thiscode); // This updates 'thisccode' by reference, no copy
117 -
    std::size_t pos = thiscode.find(".");
117 +
    std::size_t pos = thiscode.find('.');
118 118
    // substring parts
119 119
    std::string mjrin;
120 120
    String mnrout;
@@ -147,7 +147,7 @@
Loading
147 147
    const char *thiscode_cstr = strna.get_cstring();
148 148
    std::string thiscode(thiscode_cstr);
149 149
    thiscode        = trimLeftCpp(thiscode);
150 -
    std::size_t pos = thiscode.find_first_of(".");
150 +
    std::size_t pos = thiscode.find_first_of('.');
151 151
    if (pos != std::string::npos) {
152 152
      // now we assume that the mjr is snug against the left side, so we can add
153 153
      // zero padding
154 154
imilarity index 73%
155 155
ename from src/convert.h
156 156
ename to src/convert.hpp

@@ -605,7 +605,7 @@
Loading
605 605
    return(.get_fetcher_fun(var_name)())
606 606
  }
607 607
  .absent_action_switch(
608 -
    paste(var_name, "not available in icd.data regular or lazy data")
608 +
    paste(var_name, "not available in icd, even via as-yet-unloaded lazy data")
609 609
  )
610 610
}
611 611

@@ -0,0 +1, @@
Loading
1 +
unsigned char Makevars[] = { 0x00 };

@@ -10,7 +10,7 @@
Loading
10 10
#' \dontrun{
11 11
#' # get function from namespace instead of possibly getting
12 12
#' # implementation shipped with recent R versions:
13 -
#' f = getFromNamespace("R_user_dir", "icd")
13 +
#' f <- getFromNamespace("R_user_dir", "icd")
14 14
#' cached <- f("icd", "cache")
15 15
#' confd <- f("icd", "config")
16 16
#' datad <- f("icd", "data")
@@ -38,44 +38,54 @@
Loading
38 38
  path <-
39 39
    switch(which,
40 40
      data = {
41 -
        if(nzchar(p <- Sys.getenv("R_USER_DATA_DIR")))
41 +
        if (nzchar(p <- Sys.getenv("R_USER_DATA_DIR"))) {
42 42
          p
43 -
        else if(nzchar(p <- Sys.getenv("XDG_DATA_HOME")))
43 +
        } else if (nzchar(p <- Sys.getenv("XDG_DATA_HOME"))) {
44 44
          p
45 -
        else if(.Platform$OS.type == "windows")
45 +
        } else if (.Platform$OS.type == "windows") {
46 46
          file.path(Sys.getenv("APPDATA"), "R", "data")
47 -
        else if(Sys.info()["sysname"] == "Darwin")
48 -
          file.path(home, "Library", "Application Support",
49 -
            "org.R-project.R")
50 -
        else
47 +
        } else if (Sys.info()["sysname"] == "Darwin") {
48 +
          file.path(
49 +
            home, "Library", "Application Support",
50 +
            "org.R-project.R"
51 +
          )
52 +
        } else {
51 53
          file.path(home, ".local", "share")
54 +
        }
52 55
      },
53 56
      config = {
54 -
        if(nzchar(p <- Sys.getenv("R_USER_CONFIG_DIR")))
57 +
        if (nzchar(p <- Sys.getenv("R_USER_CONFIG_DIR"))) {
55 58
          p
56 -
        else if(nzchar(p <- Sys.getenv("XDG_CONFIG_HOME")))
59 +
        } else if (nzchar(p <- Sys.getenv("XDG_CONFIG_HOME"))) {
57 60
          p
58 -
        else if(.Platform$OS.type == "windows")
61 +
        } else if (.Platform$OS.type == "windows") {
59 62
          file.path(Sys.getenv("APPDATA"), "R", "config")
60 -
        else if(Sys.info()["sysname"] == "Darwin")
61 -
          file.path(home, "Library", "Preferences",
62 -
            "org.R-project.R")
63 -
        else
63 +
        } else if (Sys.info()["sysname"] == "Darwin") {
64 +
          file.path(
65 +
            home, "Library", "Preferences",
66 +
            "org.R-project.R"
67 +
          )
68 +
        } else {
64 69
          file.path(home, ".config")
70 +
        }
65 71
      },
66 72
      cache = {
67 -
        if(nzchar(p <- Sys.getenv("R_USER_CACHE_DIR")))
73 +
        if (nzchar(p <- Sys.getenv("R_USER_CACHE_DIR"))) {
68 74
          p
69 -
        else if(nzchar(p <- Sys.getenv("XDG_CACHE_HOME")))
75 +
        } else if (nzchar(p <- Sys.getenv("XDG_CACHE_HOME"))) {
70 76
          p
71 -
        else if(.Platform$OS.type == "windows")
77 +
        } else if (.Platform$OS.type == "windows") {
72 78
          file.path(Sys.getenv("LOCALAPPDATA"), "R", "cache")
73 -
        else if(Sys.info()["sysname"] == "Darwin")
74 -
          file.path(home, "Library", "Caches",
75 -
            "org.R-project.R")
76 -
        else
79 +
        } else if (Sys.info()["sysname"] == "Darwin") {
80 +
          file.path(
81 +
            home, "Library", "Caches",
82 +
            "org.R-project.R"
83 +
          )
84 +
        } else {
77 85
          file.path(home, ".cache")
78 -
      })
86 +
        }
87 +
      }
88 +
    )
79 89
80 90
  file.path(path, "R", package)
81 91
}

@@ -394,7 +394,7 @@
Loading
394 394
#' @keywords internal manip
395 395
#' @noRd
396 396
short_to_parts.icd10 <- function(x, mnr_empty = "") {
397 -
  icd10_short_to_parts_rcpp(x, mnrEmpty = mnr_empty)
397 +
  icd10ShortToParts(x, mnrEmpty = mnr_empty)
398 398
}
399 399
400 400
#' @describeIn short_to_parts Convert short format ICD-10-CM codes to parts
@@ -402,7 +402,7 @@
Loading
402 402
#' @keywords internal manip
403 403
#' @noRd
404 404
short_to_parts.icd10cm <- function(x, mnr_empty = "") {
405 -
  icd10_short_to_parts_rcpp(x, mnrEmpty = mnr_empty)
405 +
  short_to_parts.icd10(x, mnr_empty)
406 406
}
407 407
408 408
#' @describeIn short_to_parts Convert short format ICD code to parts,

@@ -1,10 +1,10 @@
Loading
1 -
#include "mapplus.h"
2 -
#include "comorbidMatMul.h"
3 -
#include "fastIntToString.h"
4 -
#include "icd_types.h"
5 -
#include "local.h"
6 -
#include "refactor.h"
7 -
#include "relevant.h"
1 +
#include "mapplus.hpp"
2 +
#include "comorbidMatMul.hpp"
3 +
#include "fastIntToString.hpp"
4 +
#include "icd_types.hpp"
5 +
#include "local.hpp"
6 +
#include "refactor.hpp"
7 +
#include "relevant.hpp"
8 8
#include <cstring>
9 9
#include <string>
10 10
11 11
imilarity index 86%
12 12
ename from src/mapplus.h
13 13
ename to src/mapplus.hpp

@@ -1,19 +1,21 @@
Loading
1 -
#include "convert10.h"
2 -
#include "convert.h"
3 -
#include "icd_types.h"
1 +
#include "convert10.hpp"
2 +
#include "convert.hpp"
3 +
#include "icd_types.hpp"
4 4
extern "C" {
5 5
#include <cstddef> // for size_t
6 6
}
7 -
#include "appendMinor.h" // for icd9MajMinToCode
8 -
#include "is.h"          // for icd9IsASingleE, icd9IsAS...
9 -
#include "manip.h"       // for icd9AddLeadingZeroesMajor
10 -
#include "util.h"        // for strimCpp, trimLeftCpp
7 +
#include "appendMinor.hpp" // for icd9MajMinToCode
8 +
#include "is.hpp"          // for icd9IsASingleE, icd9IsAS...
9 +
#include "manip.hpp"       // for icd9AddLeadingZeroesMajor
10 +
#include "util.hpp"        // for strimCpp, trimLeftCpp
11 11
#include <string>        // for string
12 12
13 13
using namespace Rcpp;
14 14
15 -
// [[Rcpp::export(icd10_short_to_parts_rcpp)]]
16 -
List icd10ShortToParts(const CV &x, const String mnrEmpty) {
15 +
// //Rcpp::export(icd10_short_to_parts_rcpp)]]
16 +
17 +
// [[Rcpp::export]]
18 +
Rcpp::List icd10ShortToParts(const Rcpp::CharacterVector & x, const Rcpp::String & mnrEmpty) {
17 19
  R_xlen_t i10sz = x.size();
18 20
  CV mjr(i10sz);
19 21
  CV mnr(i10sz);
@@ -43,7 +45,7 @@
Loading
43 45
}
44 46
45 47
// [[Rcpp::export]]
46 -
List icd10DecimalToParts(const CV x, const String mnrEmpty = "") {
48 +
List icd10DecimalToParts(const CV & x, const String & mnrEmpty) {
47 49
  CV mjrs;
48 50
  CV mnrs;
49 51
  R_xlen_t ilen = x.length();
@@ -60,7 +62,7 @@
Loading
60 62
    }
61 63
    std::string thiscode = as<std::string>(*it);
62 64
    thiscode = strimCpp(thiscode); // Updates 'thisccode' by reference, no copy
63 -
    std::size_t pos = thiscode.find(".");
65 +
    std::size_t pos = thiscode.find('.');
64 66
    // substring parts
65 67
    std::string mjrin;
66 68
    String mnrout;

@@ -1,5 +1,5 @@
Loading
1 -
#include "icd_types.h"
2 -
#include "local.h"
1 +
#include "icd_types.hpp"
2 +
#include "local.hpp"
3 3
using namespace Rcpp;
4 4
5 5
#ifndef RELEVANT_H_
@@ -21,7 +21,7 @@
Loading
21 21
      : src_map(map), relevant(findRelevant(codes)), rel(findRel(relevant)),
22 22
        hash(IHS(relevant).fill()), keys(hash.keys()) {}
23 23
  // construct from a dataframe with given columns
24 -
  Relevant(const List &map, const List &data, CV code_names)
24 +
  Relevant(const List &map, const List &data, const CV& code_names)
25 25
      : src_map(map), relevant(findRelevant(data, code_names)),
26 26
        rel(findRel(relevant)), hash(IHS(relevant).fill()), keys(hash.keys()) {
27 27
  }
@@ -32,7 +32,7 @@
Loading
32 32
  CV findRelevant(const SEXP &codes);
33 33
  // CV findRelevant(const DataFrame& data, CV code_fields);
34 34
  CV findRelevant(const List &data, const CV& code_names);
35 -
  RelMap findRel(const CharacterVector x);
35 +
  RelMap findRel(const CharacterVector& x);
36 36
}; // Relevant
37 37
38 38
#endif // RELEVANT_H_

@@ -153,7 +153,6 @@
Loading
153 153
  if (!short_code) {
154 154
    x <- decimal_to_short(x)
155 155
  }
156 -
  # Workaround until next icd.data is on CRAN
157 156
  ia <- get_icd10cm_active()
158 157
  leaf_name <- ifelse("leaf" %in% names(ia), "leaf", "billable")
159 158
  x %in% ia[ia[[leaf_name]] == 1L, "code"]

@@ -1,11 +1,11 @@
Loading
1 1
// [[Rcpp::depends(RcppEigen)]]
2 -
#include "comorbidMatMul.h"
3 -
#include "fastIntToString.h"
4 -
#include "icd_types.h"
5 -
#include "local.h"
6 -
#include "mapplus.h"
7 -
#include "refactor.h"
8 -
#include "relevant.h"
2 +
#include "comorbidMatMul.hpp"
3 +
#include "fastIntToString.hpp"
4 +
#include "icd_types.hpp"
5 +
#include "local.hpp"
6 +
#include "mapplus.hpp"
7 +
#include "refactor.hpp"
8 +
#include "relevant.hpp"
9 9
#include <cstring>
10 10
#include <string>
11 11
#include <unordered_set>
@@ -54,8 +54,8 @@
Loading
54 54
55 55
void buildVisitCodesSparseWide(
56 56
  const DataFrame &data,
57 -
  const std::string id_name,
58 -
  const CV code_names,
57 +
  const std::string& id_name,
58 +
  const CV& code_names,
59 59
  const bool validate,
60 60
  Relevant &rh,
61 61
  PtsSparse &visMat, // output
@@ -136,8 +136,8 @@
Loading
136 136
// [[Rcpp::export(comorbid_mat_mul_wide_rcpp)]]
137 137
LogicalMatrix comorbidMatMulWide(const DataFrame &data,
138 138
                                 const List &map,
139 -
                                 const std::string id_name,
140 -
                                 const CV code_names,
139 +
                                 const std::string& id_name,
140 +
                                 const CV& code_names,
141 141
                                 const bool validate) {
142 142
  VecStr out_row_names;           // size is reserved in buildVisitCodesVec
143 143
  RObject visits = data[id_name]; // does this copy??? RObject instead?
144 144
imilarity index 76%
145 145
ename from src/comorbidMatMul.h
146 146
ename to src/comorbidMatMul.hpp

@@ -91,33 +91,6 @@
Loading
91 91
  x
92 92
}
93 93
94 -
#' Internal use only: get data from the icd.data package, without relying on it
95 -
#' being attached
96 -
#'
97 -
#' Some data is hidden in active bindings, so it may be downloaded on demand,
98 -
#' and some is lazy-loaded. This will work for regular package members, active
99 -
#' bindings, and lazy data, whether or not the package is attached or loaded.
100 -
#'
101 -
#' This is really just needed for the transition from icd 3.3 to icd 4.0, and
102 -
#' icd.data > 1.0
103 -
#' @param alt If the data cannot be found, this value is returned. Default is
104 -
#'   \code{NULL}.
105 -
#' @keywords internal
106 -
#' @noRd
107 -
get_icd_data <- function(data_name, alt = NULL) {
108 -
  if (!is.character(data_name)) {
109 -
    data_name <- deparse(substitute(data_name))
110 -
  }
111 -
  ns <- asNamespace("icd")
112 -
  if (exists(data_name, ns)) {
113 -
    return(get(data_name, ns))
114 -
  }
115 -
  if (.exists_in_cache(data_name)) {
116 -
    return(.get_from_cache(data_name))
117 -
  }
118 -
  alt
119 -
}
120 -
121 94
.exists_in_ns <- function(name) {
122 95
  all(vapply(name, .exists_in_ns_single, logical(1), USE.NAMES = FALSE))
123 96
}

@@ -242,7 +242,7 @@
Loading
242 242
#' \dontrun{
243 243
#' set_icd_data_dir()
244 244
#' # or choose another directory:
245 -
#' # set_icd_data_dir("/var/cache/icd.data")
245 +
#' # set_icd_data_dir("/var/cache/icd")
246 246
#' # If you choose a custom directory, you may wish to add this command to your .Rprofile .
247 247
#' # then you may use:
248 248
#' # download_all_icd_data()
@@ -279,9 +279,12 @@
Loading
279 279
  }
280 280
  if (!dir.exists(path)) {
281 281
    created <- dir.create(path, showWarnings = TRUE, recursive = TRUE)
282 -
    if (!created) stop("Unable to create directory at: ", path, " Try ",
283 -
                       sQuote("set_icd_data_dir(\"/path/with/write/access\")")
284 -
    )
282 +
    if (!created) {
283 +
      stop(
284 +
        "Unable to create directory at: ", path, " Try ",
285 +
        sQuote("set_icd_data_dir(\"/path/with/write/access\")")
286 +
      )
287 +
    }
285 288
  }
286 289
  .set_opt("cache" = path)
287 290
  if (!.all_cached() && "download_all_icd_data" %nin% names(sys.calls())) {

@@ -4,7 +4,7 @@
Loading
4 4
#' and forms the core of the package, along with the C++ matrix code. This is
5 5
#' pure data manipulation and generalizable beyond medical data.
6 6
#'
7 -
#' The roadmap for \CRANpkg{icd} includes the optimized categorization component
7 +
#' The goals for \CRANpkg{icd} include the optimized categorization component
8 8
#' being packaged independently, and the comorbidity package taking on the
9 9
#' front-end for doing ICD-code-based comorbidities. This is in discussion.
10 10
#' @param x Data frame containing a column for an 'id' and a column for a code,

@@ -1,7 +1,7 @@
Loading
1 1
#ifndef RANGE_CONST_H_
2 2
#define RANGE_CONST_H_
3 3
4 -
#include "icd_types.h"
4 +
#include "icd_types.hpp"
5 5
6 6
// this is simplest just to hard-code
7 7
const CV vbase =

@@ -70,7 +70,9 @@
Loading
70 70
      )
71 71
    }
72 72
  } # end 400+
73 -
  json_data <- httr::content(http_response, simplifyDataFrame=TRUE)
73 +
  # encoding not specified by WHO resource (as of 2020-06-06).  Be explicit
74 +
  # about assumption.
75 +
  json_data <- httr::content(http_response, type = "text", encoding = "UTF-8")
74 76
  jsonlite::fromJSON(json_data)
75 77
}
76 78

@@ -1,5 +1,5 @@
Loading
1 -
#include "icd_types.h"
2 -
#include "local.h"
1 +
#include "icd_types.hpp"
2 +
#include "local.hpp"
3 3
extern "C" {
4 4
#include "cutil.h" // for getRListOrDfElement
5 5
}
6 6
imilarity index 100%
7 7
ename from src/icd_types.h
8 8
ename to src/icd_types.hpp

@@ -1,5 +1,5 @@
Loading
1 -
#include "icd_types.h"
2 -
#include "local.h"
1 +
#include "icd_types.hpp"
2 +
#include "local.hpp"
3 3
#include <string> // for string
4 4
5 5
using namespace Rcpp;
@@ -29,7 +29,7 @@
Loading
29 29
//' @keywords internal
30 30
//' @noRd
31 31
// [[Rcpp::export(simplify_map_lex)]]
32 -
Rcpp::List simplifyMapLexicographic(const CV &pt_codes, const List map) {
32 +
Rcpp::List simplifyMapLexicographic(const CV &pt_codes, const List& map) {
33 33
  std::string ptCode;
34 34
  size_t searchLen;
35 35
  size_t pos;

@@ -1,5 +1,5 @@
Loading
1 -
#include "attr.h"
2 -
#include "icd_types.h"
1 +
#include "attr.hpp"
2 +
#include "icd_types.hpp"
3 3
using namespace Rcpp;
4 4
5 5
//' Set ICD short-form diagnosis code attribute
6 6
imilarity index 89%
7 7
ename from src/attr.h
8 8
ename to src/attr.hpp
Files Coverage
R 49.50%
src 87.55%
Project Totals (73 files) 55.87%