Ejemplo n.º 1
0
// [[Rcpp::export]]
CV icd9ChildrenShort(CV icd9Short, const VecStr &icd9cmReal, bool onlyReal) {
  std::set<Str> out;
  if (icd9Short.size() == 0) {
    icd9Short.attr("icd_short_diag") = true;
    return icd9Short;
  }
  List parts         = icd9ShortToParts(icd9Short, "");
  CV mjr             = parts[0];
  CV mnr             = parts[1];
  CV::iterator itmjr = mjr.begin();
  CV::iterator itmnr = mnr.begin();
  for (; itmjr != mjr.end(); ++itmjr, ++itmnr) {
    Str thismjr = as<Str>(*itmjr);
    Str thismnr = as<Str>(*itmnr);
    const CV newminors =
      icd9ExpandMinor(thismnr, icd9IsASingleE(thismjr.c_str()));
    VecStr newshort = as<VecStr>(icd9MajMinToShort(thismjr, newminors));
    out.insert(newshort.begin(), newshort.end());
  }
  if (onlyReal) {
    std::set<Str> out_real;
    const std::set<Str> reals(icd9cmReal.begin(), icd9cmReal.end());
    std::set_intersection(out.begin(),
                          out.end(),
                          reals.begin(),
                          reals.end(),
                          std::inserter(out_real, out_real.begin()));
    out = out_real;
  }
  CV rcppOut                     = wrap(out);
  rcppOut.attr("icd_short_diag") = true;
  return rcppOut;
}
Ejemplo n.º 2
0
// [[Rcpp::export]]
CV icd9ChildrenShortUnordered(const CV &icd9Short,
                              const VecStr &icd9cmReal,
                              const bool onlyReal) {
  icd_set out;
  if (icd9Short.size() == 0) {
    CV out;
    out.attr("icd_short_diag") = true;
    return out;
  }
  List parts         = icd9ShortToParts(icd9Short, "");
  CV mjr             = parts[0];
  CV mnr             = parts[1];
  CV::iterator itmjr = mjr.begin();
  CV::iterator itmnr = mnr.begin();
  for (; itmjr != mjr.end(); ++itmjr, ++itmnr) {
    Str thismjr = as<Str>(*itmjr);
    Str thismnr = as<Str>(*itmnr);
    const CV newminors =
      icd9ExpandMinor(thismnr, icd9IsASingleE(thismjr.c_str()));
    VecStr newshort = as<VecStr>(icd9MajMinToShort(thismjr, newminors));
    out.insert(newshort.begin(), newshort.end());
  }
  if (onlyReal) {
    icd_set out_real;
    icd_set reals(icd9cmReal.begin(), icd9cmReal.end());
    for (icd_set::iterator j = out.begin(); j != out.end(); ++j) {
      if (reals.find(*j) != reals.end()) out_real.insert(*j);
    }
    out = out_real;
  }
  CV rcppOut                     = wrap(out);
  rcppOut.attr("icd_short_diag") = true;
  return rcppOut;
}
Ejemplo n.º 3
0
void Relevant::buildCodeSetCV(const CV &codes) {
  // over-reserve (and maybe expand), target is unique number
  allCodesSet.reserve(allCodesSet.size() + codes.size());
  DEBUG_VEC(codes);
  for (String c : codes) {
    if (c != NA_STRING) { allCodesSet.insert(c.get_cstring()); }
  }
}