Acute respiratory distress syndrome (ARDS) is a type of respiratory failure characterized by bilateral pulmonary infiltrates that cannot be explained entirely by cardiogenic pulmonary edema. ARDS is the primary cause of mortality in COVID-19 patients and one of the leading causes of morbidity and mortality in ICUs. Despite its significance and prevalence, the detection of ARDS remains highly variable and inconsistent. In this work, we develop a tool to automate the diagnosis of ARDS based on the Berlin definition to increase the accuracy of ARDS detection using electronic health record (EHR) fields. ARDSFlag applies machine learning (ML) and natural language processing (NLP) techniques to evaluate Berlin criteria by incorporating structured and unstructured data. The output is the ARDS diagnosis, onset time, and severity. We have also developed a visualization that helps clinicians efficiently assess ARDS criteria retrospectively and in real time. The method includes separate text classifiers trained using large training sets to find evidence of bilateral infiltrates in radiology reports (accuracy of 91.9%+-0.5%) and heart failure/fluid overload in radiology reports (accuracy 86.1%+-0.5%) and echocardiogram notes (accuracy 98.4%+-0.3%). A holdout set of 300 cases, which was blindly and independently labeled for ARDS by two groups of clinicians, shows that the algorithm generates an overall accuracy of 89.0%, with a specificity of 91.7%, recall of 80.3%, and precision of 75.0%. Compared with two other ARDS identification methods used in the literature, ARDSFlag shows higher performance in all accuracy measures (an increase of 25.5% in overall accuracy, 6.5% in specificity, 44.2% in recall, 31.7% in precision, and 38.20% in F1-score over the best of the two detection methods).