I will preface my comments with a note that I have watched all of Rashan Gary's games and very few of Sweat's.
If Sweat's heart condition is something minor (like a PFO) then I wouldn't hesitate to draft him since that is easily repaired. I had one since birth but it was only discovered in my late 40's when I had a minor stroke because of it. In short, it is a hole between the chambers in the heart that allows oxygenated blood to mix with the non-oxygenated. Mine allowed a small blood clot to pass through it and it caused a minor stroke. They went through my femoral artery and closed the hole so I should be good to go from here on out.
As far as Gary goes, he was not utilized properly by Harbaugh so his numbers don't jump off the page. But he more than passes the eye test. He is a freakish athlete and I would think that they could mix and match his alignment based on down and yardage to take advantage of his tools.
But, to be 100% honest, I would rather see a trade down for additional picks than either one of these guys. There are so many holes to fill that this year's draft, as it stands right now, will not address more than a couple of them. The team needs players that are at least capable of competing for backup spots, not ST players that will never see the field otherwise.