# Add Age on encounter date to encounter form

**URL:** <https://community.open-emr.org/t/add-age-on-encounter-date-to-encounter-form/5005>\
**Category:** OpenEMR Development\
**Created:** [February 17, 2013, 4:16am UTC](https://community.open-emr.org/t/add-age-on-encounter-date-to-encounter-form/5005 "2013-02-17T04:16:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [February 17, 2013, 4:16am UTC](https://community.open-emr.org/t/add-age-on-encounter-date-to-encounter-form/5005/1 "2013-02-17T04:16:38Z")

</div>

**[rmishler100](https://sourceforge.net/u/rmishler100/)** wrote on [Sunday, February 17, 2013](https://sourceforge.net/p/openemr/discussion/202506/thread/142f5902/#f16e):

I would like to add a Patient Age field to the encounter form. We need this field because we are required to produce reports that require the patient’s age during each encounter. I realize OpenEMR is displaying the age in the bar at the top of the page. Is there a way I can save that information to the form\_encounter table? I have created a field in the form\_encounter table called patient\_age but I’m not sure where to find the code or how to grab the age information already being generated by OpenEMR.  
I appreciate your help.  
richard

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [February 17, 2013, 10:55am UTC](https://community.open-emr.org/t/add-age-on-encounter-date-to-encounter-form/5005/2 "2013-02-17T10:55:37Z")

</div>

**[visolveemr](https://sourceforge.net/u/visolveemr/)** wrote on [Sunday, February 17, 2013](https://sourceforge.net/p/openemr/discussion/202506/thread/142f5902/#4656):

Hi Richard,

OpenEMR will calculate Age using "getPatientAge " function which is in the file “library/patient.inc” .  
Now you can use this function and&nbsp; pass the DOB to this.

For more info, see library/ajax/left\_nav\_encounter\_ajax.php. Here the age calculated and displayed in the main frame.

Hope this helps you.

Thanks,  
Ranjith  
[www.visolve.com](http://www.visolve.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [February 17, 2013, 7:16pm UTC](https://community.open-emr.org/t/add-age-on-encounter-date-to-encounter-form/5005/3 "2013-02-17T19:16:47Z")

</div>

**[rmishler100](https://sourceforge.net/u/rmishler100/)** wrote on [Sunday, February 17, 2013](https://sourceforge.net/p/openemr/discussion/202506/thread/142f5902/#5b06):

Ranjith, thanks for the advice. I will start there.

richard

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [February 19, 2013, 6:11am UTC](https://community.open-emr.org/t/add-age-on-encounter-date-to-encounter-form/5005/4 "2013-02-19T06:11:23Z")

</div>

**[rmishler100](https://sourceforge.net/u/rmishler100/)** wrote on [Tuesday, February 19, 2013](https://sourceforge.net/p/openemr/discussion/202506/thread/142f5902/#8004):

Hello Ranjith. I see where getPatientAge\*($prow) is happening in top.left\_nav.setPatient is being called. The real question is how do I get the system to write the results of that call to the table form\_enounter table (patient\_age field)? I want to capture the age only if a new visit is created for the patient.  
I am still learning PHP and MySQL so I’m not sure what code to add to the top.left\_nave.setPatient code to get the system to add the patient age to the table when the visit is created. I suspect it will be an INSERT of some sort.  
Thanks for your help.  
richard

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [February 19, 2013, 6:36am UTC](https://community.open-emr.org/t/add-age-on-encounter-date-to-encounter-form/5005/5 "2013-02-19T06:36:07Z")

</div>

**[rmishler100](https://sourceforge.net/u/rmishler100/)** wrote on [Tuesday, February 19, 2013](https://sourceforge.net/p/openemr/discussion/202506/thread/142f5902/#c48a):

Hello Ranjith. Just a follow-up comment. If I can get the system to save patient age when a new encounter (visit) is created then I can write a query to pull a report like the Encounter Report but with a patient age range. I need to produce a report that shows the number of patients seen by age ranges.  
Thanks for your help.  
richard
