If you are applying for adjustment of status (a green card) in the United States, you will need to have a medical exam done and submit the results to U.S. Citizenship and Immigration Services (USCIS). People applying for immigrant visas from overseas must also have a medical exam done, though the process is slightly different.
Exceptions to the exam requirement are made for some people who had the exam done before they entered the United States, such as entrants on a K-1 fiancé visa; they can use the results of their earlier medical exam, which should already be in the local USCIS office's files.
Your medical exam can be conducted only by a government-approved doctor.
If you're in the U.S., the doctor is known as a "civil surgeon." A list of these doctors is available on the Find a Doctor page of the USCIS website. You can also get this information by calling the USCIS Contact Center at 800-375-5283.
The U.S. doctor must fill out a USCIS Form called an I-693 in order to report the results of your exam. The doctor will give you your results in a sealed envelope. Do not open the report envelope—doing so will invalidate the results.
If you're overseas, the doctor is known as a "panel physician." To find one, go to the State Department's immigrant visa processing web page for medical examinations and follow the instructions. The fee varies among doctors, so you might want to call a few before choosing one. Overseas doctors fill out a form called DS-2054, and either put it in a sealed envelope or send your results directly to the consulate.
Timing is important. Someone's medical condition can change over the months and years that they might wait to be approved for a green card, and the U.S. government naturally wants the most up-to-date information.
If you're overseas, you will be instructed to go for the medical exam shortly before your visa interview.
If you're adjusting status from within the U.S., USCIS normally requires (as of a 2018 policy announcement) that the medical exam be no more than two months old when submitted to USCIS (most likely along with your adjustment of status application). However, in light of delays caused by the COVID-19 pandemic, USCIS is temporarily lifting this policy, so that exams with older physician signatures will be accepted. (This waiver is currently set to end on March 31, 2023.)
The results of the exam will then normally be good for two years after it's submitted, though USCIS announced in August of 2021 that it will temporarily extend this to a four-year validity period (again in light of COVID-related delays).
Also realize that USCIS can always order you to have a later exam done if it suspects you've since developed a medical ground of inadmissibility.
It is possible to file an adjustment application before getting the medical exam, and then bring the results of the exam to your adjustment interview, or submit them by mail if USCIS sends you a Request for Evidence (RFE). This can be a safer approach to avoid the possibility that you'll get the exam done in anticipation of filing your adjustment application but the actual filing gets delayed. Many applicants successfully use this strategy.
For what happens during the exam, and the purpose of the exam, see What the Medical Exam for a U.S. Green Card Involves.