/** programId is ignored for now as oscar doesn't support it yet. */
  public List<Prevention> getPreventionsByProgramProviderDemographicDate(
      LoggedInInfo loggedInInfo,
      Integer programId,
      String providerNo,
      Integer demographicId,
      Calendar updatedAfterThisDateExclusive,
      int itemsToReturn) {
    List<Prevention> results =
        preventionDao.findByProviderDemographicLastUpdateDate(
            providerNo, demographicId, updatedAfterThisDateExclusive.getTime(), itemsToReturn);

    LogAction.addLogSynchronous(
        loggedInInfo,
        "PreventionManager.getUpdatedAfterDate",
        "programId="
            + programId
            + ", providerNo="
            + providerNo
            + ", demographicId="
            + demographicId
            + ", updatedAfterThisDateExclusive="
            + updatedAfterThisDateExclusive.getTime());

    return (results);
  }
  public Prevention getPrevention(LoggedInInfo loggedInInfo, Integer id) {
    Prevention result = preventionDao.find(id);

    // --- log action ---
    if (result != null) {
      LogAction.addLogSynchronous(loggedInInfo, "PreventionManager.getPrevention", "id=" + id);
    }

    return (result);
  }
  public List<Prevention> getPreventionsByDemographicNo(
      LoggedInInfo loggedInInfo, Integer demographicNo) {
    List<Prevention> results = preventionDao.findUniqueByDemographicId(demographicNo);

    LogAction.addLogSynchronous(
        loggedInInfo,
        "PreventionManager.getPreventionsByDemographicNo",
        "demographicNo=" + demographicNo);

    return (results);
  }
  public List<Prevention> getUpdatedAfterDate(
      LoggedInInfo loggedInInfo, Date updatedAfterThisDateExclusive, int itemsToReturn) {
    List<Prevention> results =
        preventionDao.findByUpdateDate(updatedAfterThisDateExclusive, itemsToReturn);

    LogAction.addLogSynchronous(
        loggedInInfo,
        "PreventionManager.getUpdatedAfterDate",
        "updatedAfterThisDateExclusive=" + updatedAfterThisDateExclusive);

    return (results);
  }
  public void addPreventionWithExts(Prevention prevention, HashMap<String, String> exts) {
    if (prevention == null) return;

    preventionDao.persist(prevention);
    if (exts != null) {
      for (String keyval : exts.keySet()) {
        if (StringUtils.filled(keyval) && StringUtils.filled(exts.get(keyval))) {
          PreventionExt preventionExt = new PreventionExt();
          preventionExt.setPreventionId(prevention.getId());
          preventionExt.setKeyval(keyval);
          preventionExt.setVal(exts.get(keyval));
          preventionExtDao.persist(preventionExt);
        }
      }
    }
  }