Example #1
0
 private Result retrieveFachinfo(String lang, Medication m) {
   if (m != null) {
     String content =
         m.getContent().replaceAll("<html>|</html>|<body>|</body>|<head>|</head>", "");
     String[] titles = getSectionTitles(lang, m);
     String[] section_ids = m.getSectionIds().split(",");
     String name = m.getTitle();
     String titles_html = "<ul style=\"list-style-type:none;\n\">";
     for (int i = 0; i < titles.length; ++i) {
       if (i < section_ids.length)
         titles_html +=
             "<li><a onclick=\"move_to_anchor('"
                 + section_ids[i]
                 + "')\">"
                 + titles[i]
                 + "</a></li>";
     }
     titles_html += "</ul>";
     // Text-based HTTP response, default encoding: utf-8
     if (content != null) {
       return ok(index.render(content, titles_html, name));
     }
   }
   return ok("Hasta la vista, baby! You just terminated me.");
 }
Example #2
0
  public Result interactionsBasket(String lang, String basket) {
    String article_title = "";
    String interactions_html = "";
    String titles_html = "";

    // Decompose string coming from client and fill up linkedhashmap
    Map<String, Medication> med_basket = new LinkedHashMap<>();
    if (!basket.isEmpty() && !basket.equals("null")) {
      // Decompose the basket string
      String[] eans = basket.split(",", -1);
      for (String ean : eans) {
        if (!ean.isEmpty()) {
          Medication m = getMedicationWithEan(lang, ean);
          if (m != null) {
            article_title = m.getTitle();
            med_basket.put(ean, m);
          }
        }
      }
    }
    InteractionsData inter_data = InteractionsData.getInstance();
    interactions_html = inter_data.updateHtml(med_basket, lang);
    // Associate section titles and anchors
    String[] section_titles = inter_data.sectionTitles();
    String[] section_anchors = inter_data.sectionAnchors();
    titles_html = "<ul style=\"list-style-type:none;\n\">";
    for (int i = 0; i < section_titles.length; ++i) {
      // Spaces before and after of &rarr; are important...
      String anchor =
          section_anchors[
              i]; // section_titles[i].replaceAll("<html>", "").replaceAll("</html>",
                  // "").replaceAll(" &rarr; ", "-");
      titles_html +=
          "<li><a onclick=\"move_to_anchor('" + anchor + "')\">" + section_titles[i] + "</a></li>";
    }
    titles_html += "</ul>";
    if (interactions_html == null) interactions_html = "";

    return ok(index.render(interactions_html, titles_html, article_title));
  }
Example #3
0
 private String[] getSectionTitles(String lang, Medication m) {
   // Get section titles from chapters
   String[] section_titles = m.getSectionTitles().split(";");
   // Use abbreviations...
   String[] section_titles_abbr =
       lang.equals("de") ? models.Constants.SectionTitle_DE : Constants.SectionTitle_FR;
   for (int i = 0; i < section_titles.length; ++i) {
     for (String s : section_titles_abbr) {
       String titleA = section_titles[i].replaceAll(" ", "");
       String titleB = m.getTitle().replaceAll(" ", "");
       // Are we analysing the name of the article?
       if (titleA.toLowerCase().contains(titleB.toLowerCase())) {
         if (section_titles[i].contains("®"))
           section_titles[i] = section_titles[i].substring(0, section_titles[i].indexOf("®") + 1);
         else section_titles[i] = section_titles[i].split(" ")[0].replaceAll("/-", "");
         break;
       } else if (section_titles[i].toLowerCase().contains(s.toLowerCase())) {
         section_titles[i] = s;
         break;
       }
     }
   }
   return section_titles;
 }
Example #4
0
 private Medication cursorToMedi(ResultSet result) {
   Medication medi = new Medication();
   try {
     medi.setId(result.getLong(1)); // KEY_ROWID
     medi.setTitle(result.getString(2)); // KEY_TITLE
     medi.setAuth(result.getString(3)); // KEY_AUTH
     medi.setAtcCode(result.getString(4)); // KEY_ATCCODE
     medi.setSubstances(result.getString(5)); // KEY_SUBSTANCES
     medi.setRegnrs(result.getString(6)); // KEY_REGNRS
     medi.setAtcClass(result.getString(7)); // KEY_ATCCLASS
     medi.setTherapy(result.getString(8)); // KEY_THERAPY
     medi.setApplication(result.getString(9)); // KEY_APPLICATION
     medi.setIndications(result.getString(10)); // KEY_INDICATIONS
     medi.setCustomerId(result.getInt(11)); // KEY_CUSTOMER_ID
     medi.setPackInfo(result.getString(12)); // KEY_PACK_INFO
     medi.setAddInfo(result.getString(13)); // KEY_ADD_INFO
     medi.setSectionIds(result.getString(14)); // KEY_SECTION_IDS
     medi.setSectionTitles(result.getString(15)); // KEY_SECTION_TITLES
     medi.setContent(result.getString(16)); // KEY_CONTENT
     // KEY_STYLE... (ignore)
     medi.setPackages(result.getString(18)); // KEY_PACKAGES
   } catch (SQLException e) {
     System.err.println(">> SqlDatabase: SQLException in cursorToMedi");
   }
   return medi;
 }