How to customize the referral form?

Has anyone figured out how to include patient insurance information in the referral form?

hi @D_Amy_Martin, do you mean after you create a new transaction under Transactions from the person’s summary screen?

I’ll do screenshots tomorrow and upload them but no it’s from patient demographics page and then clicking transaction to add the referral form I want to include their insurance information on that referral form that we print out when we’re referring a patient to another provider.

hi, think we’re talking about the same method, this is an example from the demo farm,

When I get to the office tomorrow I will look at all this and see but I really hope so…

should be pretty doable, was also thinking about the standardized electronic transactions for people who have to do this every day,

Yup. You are right. I’ll let you know…


When I add the referral form under the transactions and it populates, I would like for it to include the patient’s insurance information. If it can automatically populate with the patients address and phone number and basic demographics, I would think there would be a way to include the patient’s insurance information as well.

Including patient’s insurance information in referral form requires some code customisation.
We have described some simple steps to make it happen.

  1. Include below lines in the file “interface/patient_file/transaction/print_referral.php”

Below code creates a label tag for insurance details. (Approximately line no: 55 in OpenEMR 5.0.2)

‘label_subhead_referred’ => xlt(‘For Referred Organization/Practitioner’),
‘label_insurance_name’ => xlt(‘Insurance Name’),
‘label_insurance_date’ => xlt(‘Insurance Date’)

Next step is to fetch the insurance data using existing function

if ($patient_id) {
$patdata = getPatientData($patient_id);
$insurancedata=getInsuranceData($patient_id); //New line included to fetch data
$patient_age = getPatientAge(str_replace(’-’, ‘’, $patdata[‘DOB’]));
} else {
$patdata = array(‘DOB’ => ‘’);
$patient_age = ‘’;

Also include below line, (Approximate line no: 198/ After $patdata for loop)

foreach ($insurancedata as $key => $value) {
$s = str_replace("{insurance_$key}", text($value), $s);

  1. Include the lines to display the insurance information in file “sites/default/referral_template.html”

Finally the output will be,

Try out and let us know if you have any clarifications.


Thank you. I’m going to go into the office and try this out tomorrow and hopefully, everything will work out good. Really excited.

will get this into the codebase and hopefully the next patch

will give visolve credit for the code tips :slight_smile:

1 Like

I haven’t upgraded to 5.0.2 yet. We are still using 5.0.1. When I added the extra lines of code, I ended up with a blank screen when I click the view button. I’ll work on it some more later. I do also want to include the insurance policy number on the referral form. I might wait to make these changes after I do the upgrade.

Sure, will hopefully have the 2nd patch of 5.0.2 out next weekend and will have this working by then and included

Do you know if the second patch is ready to come out? Were you able to figure out how to include the patients insurance subscriber ID along with the insurance name???

hi @D_Amy_Martin, won’t be much longer for patch 2 or you could use these file changes, Referral (#2729) · openemr/openemr@4c62698 · GitHub

1 Like

I know this is an old topic, but I have a suggestion for a change in the referral form.

The printout of the form is created by: “…openemr/sites/default/referral_template.html”
and I suggest this change:

`diff referral_template.html referral_template.html-back
<    <td style="width:1%;white-space:nowrap">&nbsp; {label_dob} &nbsp;</td>
<    <td class='under'>{pt_DOB}&nbsp;</td>
>    <td style="width:1%;white-space:nowrap">&nbsp; {label_age} &nbsp;</td>
>    <td class='under'>{pt_age}&nbsp;</td>
<    <td style="width:1%;white-space:nowrap">&nbsp;{label_dob} &nbsp;</td>
<    <td class='under'>{pt_DOB}&nbsp;</td>
>    <td style="width:1%;white-space:nowrap">&nbsp; Age &nbsp;</td>
>    <td class='under'>{pt_age}&nbsp;</td>
<    <td style="width:1%;white-space:nowrap">&nbsp; {label_dob} &nbsp;</td>
<    <td class='under'>{pt_DOB}&nbsp;</td>
>    <td style="width:1%;white-space:nowrap">&nbsp; {label_age} &nbsp;</td>
>    <td class='under'>{pt_age}&nbsp;</td>`

and for “…/openemr/interface/patient_file/transaction/print_referral.php”

diff print_referral.php print_referral.php~
<     $timestamp = strtotime($patdata['DOB']);
<     $patient_DOB = date("m/d/Y", $timestamp);
< $s = str_replace("{pt_DOB}", text($patient_DOB), $s);

Most consultants want the patient’s DOB for insurance verification and can calculate the age of the patient on their own!

The “date” function can be customized to your region… “m/d/Y” , “Y/m/d”, etc. There may be a global that I am unaware of.

1 Like