40 ppm for nitrates is high. I would step up water changes and filter maintance (clean out your filters) to get the nitrates down. Add some aquarium salt to the water 1.5 tablespoon per 5 gallons of tank water. Do a large 50% water change before adding the salt. If you have old carbon in the filter throw it out. High levels of nitrate stress the fish and weaken the immune system making them more suseptable to diseases. Start like this and in three of days report back and let us know how it's doing. At that point we'll see if meds are necessary.