SQL Server: Case expression returns NULL even with an ELSE
I would try adding some ISNULL functions to the left sides of the Case checks (h.encounter_date and h2.encounter_date), as I don't see a WHERE h.encounter_date/h2.encounter_date IS NOT NULL in your WHERE clause.