Medical records are not a website, so its logic should not be in PHP.
A frontend for medical data? Yes, a HIS? NO