A senior official was so worried a new $764 million medical records system for the municipal hospital system was launching too early that he resigned, comparing it to the disastrous space shuttle Challenger launch in 1986.

In a “resignation and thank-you” email last week, Dr. Charles Perry urged colleagues at NYC Health + Hospitals — formerly the Health and Hospitals Corp. — to sound the alarm and press for an “external review” to stop the system from going live next month.

Perry was chief medical information officer of Queens and Elmhurst Hospital Centers, the first scheduled to get the new electronic medical data system.

In his email, Perry offered a comparison to the launch of the Challenger — aboard which seven crew members died when it exploded 73 seconds after liftoff on Jan. 28, 1986 — and cited a presidential panel’s report examining how the disaster occurred.

“For a successful technology, ­reality must take precedence over public relations, for nature cannot be fooled,” Perry wrote in his ­email, quoting from the report.

“Please assure your wisdom is heard about the reasonableness of the April 1st deadline” to launch the medical records system.

Perry went on to urge a short delay despite “vehement entreaties to make the April 1st date by officials and consultants with jobs and paydays on the line.”

Agency president Dr. Ramanathan Raju has repeatedly told colleagues his job is on the line if the deadline isn’t met, sources said.

Perry, a medical doctor with an MBA, declined to comment.

But two sources noted he played a “crucial and pivotal” role in ­ensuring that the launch of the system known as Epic went off without a hitch.

“He took a stand,” said one insider. “He wasn’t going to take part in something that was going to compromise patient safety.”

City officials contend that Epic remains “on-time and within budget.”

“The idea that we’d jeopardize patients to meet a deadline is simply wrong,” said Karen Hinton, Mayor Bill de Blasio’s spokeswoman.

“If a patient safety issue is identified, the project will stop until it is addressed.

“NYC Health + Hospitals and its Epic implementation experts have assembled a team of about 900 technicians and Epic experts who will work around the clock through the week surrounding the transition in both Queens and at remote data centers to ensure we shift to the new system as smoothly as possible.”