Codes to access demographic of a patient

Hi,

I want to know how to access to the codes of the demographic of a patient when I print out on prescription.

The codes on prescription on file C_prescription.class.php on lines 402 to 410 are as follows:

echo ("<td class='bordered'>\n");
echo ('<b><span class="small">' . xl('Date of Birth') . '</span></b>' . '<br>');
echo ($p->patient->date_of_birth );
echo ("</td>\n");
echo ("</tr>\n");
echo ("<tr>\n");
echo ("<td class='bordered'>\n");
echo ('<b><span class="small">' . xl('Medical Record #') . '</span></b>' . '<br>');
echo (str_pad($p->patient->get_pubpid(), 10, "0", STR_PAD_LEFT));

I want to change the Medical Record # to Social security #. Please advise how I can do this.

Thanks

Hi jhunyan,

In order to Change the field in prescription as you mentioned.
Open the file C_Prescription.class.php
Search for the field “Medical Record”,you will get two results.Change it as “Social security”
Finally save and check for the change.

Thanks,
ViSolve

Hi,

Thanks for you reply. I know how to change the field from

echo (’’ . xl(‘Medical Record #’) . ‘’ . ‘
’);
echo (str_pad($p->patient->get_pubpid(), 10, “0”, STR_PAD_LEFT));

to

echo (’’ . xl(‘Social security’) . ‘’ . ‘
’);
echo ($p->patient-> ??? );

What is the codes to extract social security number so when I print the prescription, it will display the social security number automatically?

Please advise

Hi @jhunyan,

Try this,

Inside of the Patient class located in openemr/Patient.class.php at master · openemr/openemr · GitHub you’re going to add a new function. I’m away from my laptop so I’m gonna do this the best I can from my phone.

public function get_ssn()
{
    return $this->ssn;
}

And then, in the populate function you’ll need to add the colum ss To the select query and finally in the if statement a couple of lines below add $this->ssn = $res['ss'];

That should allow you to go back to the C_prescription file and replace the call to $p->patient->get_pubpid() with $p->patient->get_ssn()

Sorry I can’t actually test any of that, nothing like writing code from your phone :smiley:

Let me know if that works. I’ll try to test this later tonight

Hi Robert,

Thank you for your reply.

I tried what you told me but it did not work. I changed the codes in patient class as below

/************************************************************************
/usr/share/apps/umbrello/headings/heading.php

This file was generated on %date% at %time%
The original location of this file is /home/duhlman/uml-generated-code/prescription.php
**************************************************************************/

require_once("ORDataObject.class.php");
require_once("Provider.class.php");
/**
 * class Patient
 *
 */

class Patient extends ORDataObject{
	var $id;
	var $pubpid;
	var $lname;
	var $mname;
	var $fname;
	var $date_of_birth;
	var $provider;

	/**
	 * Constructor sets all Prescription attributes to their default value
	 */
	function __construct($id = "")	{
		$this->id = $id;
		$this->_table = "patient_data";
		$this->pubpid = "";
		$this->lname = "";
		$this->mname = "";
		$this->fname = "";
		$this->dob 	 = "";
		$this->provider = new Provider();
		$this->populate();


	}
	public function get_ssn()
    {return $this->ssn;
    }
	function populate() {
		if (!empty($this->id)) {
			$res = sqlQuery("SELECT providerID,fname,lname,mname ".
                                        ", DATE_FORMAT(DOB,'%m/%d/%Y') as date_of_birth ".
                                        ", pubpid ".
                                        " from " . $this->_table ." where pid =". add_escape_custom($this->id));
			if (is_array($res)) {
				$this->pubpid = $res['pubpid'];
				$this->lname = $res['lname'];
				$this->mname = $res['mname'];
				$this->fname = $res['fname'];
				$this->provider = new Provider($res['providerID']);
				$this->date_of_birth = $res['date_of_birth'];
				$this->ssn = $res['ss'];
			}
		}
	}
	
	function get_id() { return $this->id; }
	function get_pubpid() { return $this->pubpid; }
	function get_lname() { return $this->lname; }
	function get_name_display() { return $this->fname . " " . $this->lname; }
	function get_provider_id() { return $this->provider->id; }
	function get_provider() { return $this->provider; }
	function get_dob () { return $this->date_of_birth; }
	
} // end of Patient

For the codes in C_Prescription.class.php, on lines 410, I change codes as you advised echo ($p->patient->get_ssn());

Please advise.

Thanks

Replace the above line with:

$res = sqlQuery("SELECT providerID,fname,lname,mname, ss ".
                                        ", DATE_FORMAT(DOB,'%m/%d/%Y') as date_of_birth ".
                                        ", pubpid ".
                                        " from " . $this->_table ." where pid =". add_escape_custom($this->id));

You’ll noticed I added the ss field after fname,lname,mname

Hi Robert,

It is working. Thanks