Пример #1
0
  /**
   * Saves a patient in the database
   *
   * @param p The Patient object to save
   */
  public void createPatient(Patient p) {
    // check if it is new record in DB
    if (!isExist(p)) {
      try {
        statement =
            con.prepareStatement(
                "INSERT INTO patients (firstname, lastname, preferredname, volunteer,"
                    + " gender, notes, volunteer2, alerts, myoscar_verified, clinic, availability) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
        statement.setString(1, p.getFirstName());
        statement.setString(2, p.getLastName());
        statement.setString(3, p.getPreferredName());
        statement.setInt(4, p.getVolunteer());
        statement.setString(5, p.getGender());
        statement.setString(6, p.getNotes());
        statement.setInt(7, p.getPartner());
        statement.setString(8, p.getAlerts());
        statement.setString(9, p.getMyoscarVerified());
        statement.setString(10, p.getClinic());
        statement.setString(11, p.getAvailability());

        statement.execute();
      } catch (SQLException e) {
        System.out.println("Error: Could not create patient");
        e.printStackTrace();
      } finally {
        try {
          statement.close();
        } catch (Exception e) {
          // Ignore
        }
      }
    }
  }
Пример #2
0
  /**
   * Changes a patient in the database
   *
   * @param p The Patient object containing the new data (should have the same ID as the patient to
   *     replace)
   */
  public void updatePatient(Patient p) {
    try {
      statement =
          con.prepareStatement(
              "UPDATE patients SET firstname=?, lastname=?, preferredname=?, volunteer=?, "
                  + "gender=?, notes=?, clinic=?, availability=?, myoscar_verified=?, alerts=?, volunteer2=? WHERE patient_ID=?");
      statement.setString(1, p.getFirstName());
      statement.setString(2, p.getLastName());
      statement.setString(3, p.getPreferredName());
      statement.setInt(4, p.getVolunteer());
      statement.setString(5, p.getGender());
      statement.setString(6, p.getNotes());
      statement.setString(7, p.getClinic());
      statement.setString(8, p.getAvailability());
      statement.setString(9, p.getMyoscarVerified());
      statement.setString(10, p.getAlerts());
      statement.setInt(11, p.getPartner());
      statement.setInt(12, p.getPatientID());

      statement.execute();
    } catch (SQLException e) {
      System.out.println("Error: Could not update patient");
      e.printStackTrace();
    } finally {
      try {
        statement.close();
      } catch (Exception e) {
        // Ignore
      }
    }
  }
Пример #3
0
  /** @return a list of patients who have availability */
  public List<Patient> getAllPatientsWithAvailability() {
    List<Patient> patients = getAllPatients();
    List<Patient> aList = new ArrayList<Patient>();
    String pAvailability;

    for (Patient p : patients) {
      pAvailability = p.getAvailability();

      if ((!Utils.isNullOrEmpty(pAvailability))
          && (!pAvailability.equals("1non,2non,3non,4non,5non"))) aList.add(p);
    }

    return aList;
  }