A weakly supervised transformer for rare disease diagnosis and subphenotyping from EHRs with pulmonary case studies | Synapse