Hospitals collect discharge data through Electronic Health Records (EHR) systems. Upon a patient's discharge, healthcare providers document various elements including the patient's demographic information, primary and secondary diagnoses, procedures performed, length of hospital stay, and discharge status. These records are then aggregated and often submitted to central databases maintained by healthcare authorities or research institutions.