; and (II) began training residents for the first time in a new medical residency training program (as defined in paragraph (l) of such section) beginning on the date on which such hospital became a qualifying hospital. (ii) Special rule for qualifying hospitals in cap-building period In the case of a qualifying hospital with an approved medical residency training program that, excluding the treatment described in clause (i), is a hospital that had no allopathic or osteopathic residents in its most recent cost reporting period ending on or before December 31, 1996, and began training residents for the first time in a new medical residency training program (as defined in paragraph (l) of such section) during the 5-year period ending on the date described in clause (i)(II) with respect to such hospital, in lieu of applying such clause, the Secretary shall provide that the provisions of subsection (e) of section 413.79 of title 42, Code of Federal Regulations (or a successor regulation), shall apply with respect to such hospital for an additional 5 years beyond the period during which such provisions would otherwise have applied to such hospital. (iii) Definition In this subparagraph: (I) Qualifying hospital The term qualifying hospital means a hospital that— (aa) establishes a shortage specialty program (as defined in subclause (II)) during the 5-year period beginning on the date of the enactment of this subparagraph