Answer
In the Name of Allah, Most Gracious, Most Merciful.
All praise and thanks are due to Allah, and peace and blessings be upon His Messenger.
In this fatwa:
It is permitted to do an autopsy or dissect the bodies of the deceased for security, research, or educational purposes.
Answering your question, The Assembly of Muslim Jurists of America, states:
It is permitted to do an autopsy or dissect the bodies of the deceased for security, research, or educational purposes. For the permissibility, the following is required: the consent of the deceased, their guardian, or the authorities (in the case of criminal investigations and epidemic diseases), the presence of a need, the absence of an alternative, respect for the body during the autopsy, and the burial of its remains afterward
Almighty Allah knows best.
Source: AMJA Online.
Read also:
Withdraw or Withhold Life Sustaining Care: Permissible in Islam?
When Can You Pull the Plug on Life Support?
Stopping Mechanical Ventilation and Circulatory Support at Cessation of Heartbeat: Permissible?Advance Directives and Living Will for Muslims