1570s, "residence;" see resident + abstract noun suffix -cy. Hospital sense is from 1924.
Entries linking to residency
resident n.
mid-15c., "an inhabitant, one who dwells in a place permanently or for a considerable time," from resident (adj.). Meaning "medical graduate doing supervised specialized practice in a hospital as training" is attested by 1892, American English.
-cy
abstract noun suffix of quality or rank, from Latin -cia, -tia, from Greek -kia, -tia, from abstract ending -ia (see -ia) + stem ending -c- or -t-. The native correspondents are -ship, -hood.