private void replaceDocument(AttachedDocumentsType attachments, String id, String value) {
    List<DocumentType> toRemove = new ArrayList<DocumentType>();
    List<DocumentType> attachment = attachments.getAttachment();
    for (DocumentType doc : attachment) {
      if (id.equals(doc.getObjectId())) {
        doc.setName(value);
      } else if (value.equals(doc.getName())) {
        toRemove.add(doc);
      }
    }

    attachments.getAttachment().removeAll(toRemove);
  }
  /**
   * Binds the model to the request attributes.
   *
   * @param enrollment the model to bind from
   * @param mv the model and view to bind to
   * @param readOnly true if the view is read only
   */
  public void bindToPage(
      CMSUser user, EnrollmentType enrollment, Map<String, Object> mv, boolean readOnly) {
    attr(mv, "bound", "Y");
    ProviderInformationType provider = XMLUtility.nsGetProvider(enrollment);
    AttachedDocumentsType attachments = XMLUtility.nsGetAttachments(provider);
    List<DocumentType> attachment = attachments.getAttachment();
    for (DocumentType doc : attachment) {
      if (DocumentNames.COMMUNITY_HEALTH_BOARD_DHS_CONTRACT.value().equals(doc.getName())) {
        attr(mv, "dhsContract", doc.getObjectId());
      }
    }

    FacilityCredentialsType creds = XMLUtility.nsGetFacilityCredentials(enrollment);
    attr(mv, "chbIndicator", creds.getCommunityHealthBoard());
  }