ok guys i figured out the solution. It worked for me on localhost as well as on live server.
edit
sudo nano /etc/apache2/sites-enabled/000-default.conf
at bottom add
Add at the very bottom inside <VirtualHost *:80>:
— OpenEMR popup URL fix —
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/open72/interface/new/new_search_popup.php&close$
RewriteRule ^ /open72/interface/new/new_search_popup.php?close [L,QSA]
save and exit, then
sudo a2enmod rewrite
sudo systemctl restart apache2
logout and login again, try creating a new pt, it works.