public void testGetFluShotDelinquents()
      throws DBException, IOException, FileNotFoundException, SQLException {
    gen.patient1();
    gen.patient2();
    gen.patient3();
    List<VisitReminderReturnForm> visRems = visRemDAO.getFluShotDelinquents(LHCP);

    assertEquals(2, visRems.size());
    VisitReminderReturnForm reminder = visRems.get(0);
    assertEquals(reminder.getLastName(), "Needs");
    assertEquals(reminder.getPatientID(), 3);
    /*
     * We need to account for "today" changing. Note that tests should NOT normally have if-statements in
     * them.
     */
    if (getCurrentMonth() >= 8 && getCurrentMonth() <= 11) // if we are in [Sep,Dec]
    assertEquals(VisitFlag.MISSING_MEDICATION, reminder.getVisitFlags()[0].getType());
    else
      // otherwise we are in [Jan,Aug]
      assertEquals(VisitFlag.MISSED_MEDICATION, reminder.getVisitFlags()[0].getType());
    assertEquals(reminder.getVisitFlags()[0].getValue(), "Flu Shot");
    reminder = visRems.get(1);
    assertEquals(reminder.getLastName(), "Person");
    assertEquals(reminder.getPatientID(), 1);
    if (getCurrentMonth() >= 8 && getCurrentMonth() <= 11) // if we are in [Sep,Dec]
    assertEquals(reminder.getVisitFlags()[0].getType(), VisitFlag.MISSING_MEDICATION);
    else
      // otherwise we are in [Jan,Aug]
      assertEquals(reminder.getVisitFlags()[0].getType(), VisitFlag.MISSED_MEDICATION);
    assertEquals(reminder.getVisitFlags()[0].getValue(), "Flu Shot");
  }
 public void testGetDiagnosedVisitNeeders()
     throws DBException, IOException, FileNotFoundException, SQLException {
   gen.patient1();
   gen.patient2();
   gen.patient3();
   List<VisitReminderReturnForm> visRems = visRemDAO.getDiagnosedVisitNeeders(LHCP);
   VisitReminderReturnForm reminder = visRems.get(0);
   assertEquals(reminder.getLastName(), "Person");
   assertEquals(reminder.getPatientID(), 1);
   assertEquals(reminder.getVisitFlags()[0].getType(), VisitFlag.DIAGNOSED);
   assertEquals(reminder.getVisitFlags()[0].getValue(), "250.00");
 }
  public void testGetFluShotDelinquentsEmptyList() throws Exception {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    gen.patient1();
    gen.patient2();
    gen.patient3();
    boolean thisYear = DateUtil.currentlyInMonthRange(9, 12);

    java.sql.Date september = new java.sql.Date(0l), december = new java.sql.Date(0l);
    DateUtil.setSQLMonthRange(september, 8, thisYear ? 0 : 1, december, 11, thisYear ? 0 : 1);
    try {
      conn = factory.getConnection();
      ps =
          conn.prepareStatement(
              "SELECT DISTINCT "
                  + "? as hid, ov.patientid, p.lastname, p.firstname, "
                  + "p.phone "
                  + "FROM officevisits ov, patients p "
                  + "WHERE ov.patientid=p.mid "
                  + "AND p.dateofdeath IS NULL "
                  + "AND p.dateofbirth < DATE_SUB(CURDATE(), INTERVAL 50 YEAR) "
                  + "AND patientid NOT IN "
                  + "(SELECT patientid FROM officevisits ov, ovmedication om "
                  + "WHERE ov.id=om.visitid "
                  + "AND NDCode IN (90656, 90658, 90660) "
                  + "AND ((StartDate BETWEEN ? AND ?) "
                  + "OR (EndDate BETWEEN ? AND ?))) "
                  + "ORDER BY lastname, firstname, ov.patientid");
      ps.setLong(1, this.LHCP);
      ps.setDate(2, september);
      ps.setDate(3, december);
      ps.setDate(4, september);
      ps.setDate(5, december);
      rs = ps.executeQuery();
      VisitReminderReturnFormLoader loader = new VisitReminderReturnFormLoader();
      List<VisitReminderReturnForm> patients = loader.loadList(rs);
      assertEquals(2, patients.size());
      VisitReminderReturnForm patient1 = patients.get(0);
      assertEquals(9000000003l, patient1.getHcpID());
      assertEquals(3l, patient1.getPatientID());
      assertEquals("Care", patient1.getFirstName());
      assertEquals("919-971-0000", patient1.getPhoneNumber());
    } finally {
      DBUtil.closeConnection(conn, ps);
    }
  }