예제 #1
0
  private void doLoad() {
    if (logger == null) logger = new Logger();

    if (loaded) return;

    try {
      logger.log("Loading State Prescription Variances...");
      RcopiaDb db = DatabaseFactory.instance().get(STATE_PHARMACY_VARIANCES, logger);

      ArrayList variances = db.getAll();
      createMap(variances);
    } catch (Exception e) {
      logger.log(e);
      ErrorMailServer.instance()
          .mail("Cannot load State Prescription Variances: " + e.getMessage());
      throw new SystemErrorException(
          "Cannot load  State Prescription Variances: " + e.getMessage());
    }

    loaded = true;
  }
예제 #2
0
  private void createMap(ArrayList variances) throws IOException {
    if (variances == null) return;

    Iterator iter = variances.iterator();
    while (iter.hasNext()) {
      RcopiaInfo variance = (RcopiaInfo) iter.next();
      String stateCode = variance.getString(STATECODE);
      if (Str.isEmpty(stateCode)) {
        logger.log("No statecode in variance record " + variance.getID());
        continue;
      }

      String key = variance.getString(KEY);
      String value = variance.getString(VALUE);

      HashMap stateMap = (HashMap) varianceMap.get(stateCode);
      if (stateMap == null) {
        stateMap = new HashMap();
        varianceMap.put(stateCode, stateMap);
      }

      stateMap.put(key, value);
    }
  }