eClinicalWorks interview question

was made to write a big join query