/**
   * Populates the answer attributes for patient info.
   *
   * @param p the parent procedure.
   * @param pi patient information.
   */
  public static void populateSpecialElements(Procedure p, PatientInfo pi) {
    if (pi == null || !pi.isConfirmed() || !p.current().hasSpecialElement()) {
      return;
    }
    List<ProcedureElement> specialElements = p.current().getSpecialElements();

    for (ProcedureElement element : specialElements) {
      String id = element.getId();
      if (pi != null) {
        element.setAnswer(pi.getAnswerForId(id));
      }
    }
  }
  /** Validates non-standard patient elements in a procedure */
  private static boolean validateSpecialElements(Procedure p, PatientInfo pi)
      throws ValidationError {
    List<ProcedureElement> specialElements = p.current().getSpecialElements();

    if (pi == null) pi = new PatientInfo();

    for (ProcedureElement el : specialElements) {
      String element_id = el.getId();
      String element_answer = el.getAnswer().trim().toLowerCase();

      if (element_id.equals("patientId")) {

      } else if (element_id.equals("patientFirstName")) {

      } else if (element_id.equals("patientLastName")) {

      } else if (element_id.equals("patientGender")) {

      } else if (element_id.equals("patientBirthdateMonth")) {
        String year = p.current().getElementValue("patientBirthdateYear");
        try {
          int yearValue = Integer.parseInt(year);
          int currentYear = Calendar.getInstance().get(Calendar.YEAR);
          Log.i(TAG, "Validating year: " + yearValue + " against " + currentYear);
          if (yearValue > currentYear || yearValue < currentYear - 120) {
            throw new ValidationError(
                "The year entered is not "
                    + "valid (in the future or too far in the past)."
                    + "Please try again.");
          }
        } catch (Exception e) {
          throw new ValidationError(
              "The year entered is not a " + "number. Please enter a number.");
        }
      }
    }
    return true;
  }