コード例 #1
0
 public Set<String> getBrandNamesByNameAndUnii(String name, String unii) throws IOException {
   UriComponentsBuilder builder =
       UriComponentsBuilder.fromHttpUrl(this.fdaDrugLabelUrl)
           .queryParam(
               "search",
               "(openfda.unii:"
                   + fixTerm.makeFdaSafe(unii)
                   + ")+AND+(openfda.brand_name:"
                   + fixTerm.makeFdaReady(fixTerm.makeFdaSafe(name))
                   + ")")
           .queryParam("count", "openfda.brand_name.exact");
   this.apiKey.addToUriComponentsBuilder(builder);
   try {
     String result = rest.getForObject(builder.build().toUri(), String.class);
     FieldFinder finder = new FieldFinder("term");
     return finder.find(result);
   } catch (HttpClientErrorException notFound) {
     if (notFound.getStatusCode() == HttpStatus.NOT_FOUND) {
       // server reported 404, handle it by returning no results
       log.warn("No brand name data found for search by name: " + name + " and unii " + unii);
       return Collections.emptySet();
     }
     throw notFound;
   }
 }
コード例 #2
0
 public String getGenericNameByRxcui(Long rxcui) throws IOException {
   if (rxcui == null) {
     return "";
   }
   UriComponentsBuilder builder =
       UriComponentsBuilder.fromHttpUrl(this.nlmRxnavUrl + "/" + rxcui + "/allProperties.json")
           .queryParam("prop", "names");
   String result = rest.getForObject(builder.build().toUri(), String.class);
   FieldFinder finder = new FieldFinder("propValue");
   Set<String> generics = finder.find(result);
   if (generics.isEmpty()) {
     return "";
   } else {
     return generics.iterator().next();
   }
 }
コード例 #3
0
 public Long getRxcuiByUnii(String unii) throws IOException {
   UriComponentsBuilder builder =
       UriComponentsBuilder.fromHttpUrl(this.nlmRxnavUrl + ".json")
           .queryParam("idtype", "UNII_CODE")
           .queryParam("id", URLEncoder.encode(unii, StandardCharsets.UTF_8.name()));
   String result = rest.getForObject(builder.build().toUri(), String.class);
   FieldFinder finder = new FieldFinder("rxnormId");
   for (String id : finder.find(result)) {
     try {
       return Long.parseLong(id);
     } catch (NumberFormatException nfe) {
       // ignore invalid ids
       log.warn("Got invalid rxnormId from Rxnav query on unii" + unii);
     }
   }
   return null;
 }