public ArrayList get(long drugID) throws IOException { load(); if (LOAD_INTO_MEMORY) return (ArrayList) doseMap.get(drugID); RcopiaDb db = user.getDb(DOSE_CHECK); String cond = DRUG_ID + "=" + drugID + " AND " + IS_MAINTENANCE_DOSE + "=" + Str.quote(Y); return db.getByConditions(cond); }
private static void createMap() throws IOException { if (manufacturers == null) return; Iterator iter = manufacturers.iterator(); while (iter.hasNext()) { RcopiaInfo item = (RcopiaInfo) iter.next(); map.put(item.getID(), item); } }
private static void loadDoses() throws IOException { RcopiaDb db = DatabaseFactory.instance().get(DOSE_CHECK, Display.getMasterLogger()); ArrayList doses = db.getAll(); Iterator iter = doses.iterator(); while (iter.hasNext()) { RcopiaInfo info = (RcopiaInfo) iter.next(); if (info.isDeleted()) continue; long drugID = info.getInt(DRUG_ID); if (drugID == 0) continue; if (!Y.equalsIgnoreCase(info.getString(IS_MAINTENANCE_DOSE))) continue; ArrayList list = (ArrayList) doseMap.get(drugID); if (list == null) { list = new ArrayList(); doseMap.put(drugID, list); } list.add(info); } }
protected static synchronized void doLoad() { if (loaded) return; doseMap.clear(); try { Display.masterLog("Loading dose check information..."); loadDoses(); Display.masterLog("Loaded dose check information."); } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("Cannot load dose check information"); } loaded = true; }
public static RcopiaInfo get(long id) { load(); return (RcopiaInfo) map.get(id); }