Trouble Adding Existing Variables (UPIN, DEA, NPI, Allergies) to C_Prescription.class.php for PDF Display

I’ve been working on modifying the C_Prescription.class.php file to include some existing variables, namely UPIN, DEA, allergyes and NPI, in the medical prescription PDF. However, I’m encountering difficulties getting them to appear. I’ve tried several approaches, but none seem to work. Could anyone provide guidance on how to properly include these variables so they show up in the PDF?

Thank you in advance for your help!"

This is my code:

function multiprint_header(&$pdf, $p)
{
$this->providerid = $p->provider->id;
//print header
$pdf->ezImage($GLOBALS[‘oer_config’][‘prescriptions’][‘logo’], null, ‘30’, ‘’, ‘center’, ‘’);
$pdf->ezColumnsStart(array(‘num’ => 2, ‘gap’ => 10));
$res = sqlQuery(“SELECT concat(’’,f.name,’\n’,f.street,’\n’,f.city,’, ‘,f.state,’ ‘,f.postal_code,’\nTel:’,f.phone,if(f.fax != ‘’,concat(’\nFax: ‘,f.fax),’’)) addr FROM users JOIN facility AS f ON f.name = users.facility where users.id =’” .
add_escape_custom($p->provider->id) . “’”);
$pdf->ezText($res[‘addr’] ?? ‘’, 10);
$my_y = $pdf->y;
$pdf->ezNewPage();
$pdf->ezText(’’ . $p->provider->get_name_display() . ‘’, 10);
//Especialidad y Universidad
if ($GLOBALS[‘rx_enable_upin’]) {
if ($this->is_faxing || $GLOBALS[‘rx_show_upin’]) {
$pdf->ezText(’’ . xl(‘Universidad’) . ‘:’ . $p->provider->upin, 12);
} else {
$pdf->ezText(’’ . xl(‘Universidad’) . ‘: ________________________’, 12);
}
}
if ($GLOBALS[‘rx_enable_NPI’]) {
if ($this->is_faxing || $GLOBALS[‘rx_show_NPI’]) {
$pdf->ezText(’’ . xl(‘Especialidad’) . ‘:’ . $p->provider->npi, 12);
} else {
$pdf->ezText(’’ . xl(‘Especialidad’) . ‘: ________________________’, 12);
}
}
// A client had a bad experience with a patient misusing a DEA number, so
// now the doctors write those in on printed prescriptions and only when
// necessary. If you need to change this back, then please make it a
// configurable option. Faxed prescriptions were not changed. – Rod
// Now it is configureable. Change value in
// Administration->Globals->Rx
if ($GLOBALS[‘rx_enable_DEA’]) {
if ($this->is_faxing || $GLOBALS[‘rx_show_DEA’]) {
$pdf->ezText(’’ . xl(‘Cédula Profesional’) . ‘:’ . $p->provider->federal_drug_id, 10);
} else {
$pdf->ezText(’’ . xl(‘Cédula Profesional’) . ‘: ________________________’, 10);
}
}

if ($GLOBALS['rx_enable_NPI']) {
    if ($this->is_faxing || $GLOBALS['rx_show_NPI']) {
            $pdf->ezText('<b>' . xl('Cédula Especialidad') . ':</b>' . $p->provider->npi, 10);
    } else {
        $pdf->ezText('<b>' . xl('Cédula Especialidad') . ':</b> _________________________', 10);
    }
}

if ($GLOBALS['rx_enable_SLN']) {
    if ($this->is_faxing || $GLOBALS['rx_show_SLN']) {
        $pdf->ezText('<b>' . xl('Registro Sanitario SSG') . ':</b>' . $p->provider->state_license_number, 10);
    } else {
        $pdf->ezText('<b>' . xl('Registro Sanitario SSG') . ':</b> ___________________', 10);
    }
}

    $pdf->ezColumnsStop();
    if ($my_y < $pdf->y) {
        $pdf->ezSetY($my_y);
    }

    $pdf->ezText('', 10);
    $pdf->setLineStyle(1);
    $pdf->ezColumnsStart(array('num' => 2));
    $pdf->line($pdf->ez['leftMargin'], $pdf->y, $pdf->ez['pageWidth'] - $pdf->ez['rightMargin'], $pdf->y);
    $pdf->ezText('<b>' . xl('Nombre de Paciente') . '</b>', 6);
    $pdf->ezText($p->patient->get_name_display(), 10);
    
    // Mostrar la fecha de nacimiento
    $pdf->ezText('<b>' . xl('Fecha de Nacimiento') . '</b>', 6);
    $pdf->ezText($p->patient->date_of_birth, 10);

     // Calcular la edad actual del paciente a partir de su fecha de nacimiento
     $dateOfBirth = new DateTime($p->patient->date_of_birth);
     $currentDate = new DateTime();
     $age = $currentDate->diff($dateOfBirth)->y;

     // Mostrar la edad del paciente
     $pdf->ezText('<b>' . xl('Edad') . '</b>', 6);
     $pdf->ezText($age . ' años', 10);

     //Alergias de paciente
     $pdf->ezText('<b>' . xl('Alérgias') . '</b>', 6);
     $pdf->ezText($codeListName . ' años', 10);

    $my_y = $pdf->y;
    $pdf->ezNewPage();
    $pdf->line($pdf->ez['leftMargin'], $pdf->y, $pdf->ez['pageWidth'] - $pdf->ez['rightMargin'], $pdf->y);

    //Fecha
    $pdf->line($pdf->ez['leftMargin'], $pdf->y, $pdf->ez['pageWidth']-$pdf->ez['rightMargin'], $pdf->y);
    $pdf->ezText('<b>' . xl('Fecha') . '</b>', 6);
    $pdf->ezText(date ('d/m/Y'), 10);
    
    $pdf->ezText('');
    $pdf->line($pdf->ez['leftMargin'], $pdf->y, $pdf->ez['pageWidth'] - $pdf->ez['rightMargin'], $pdf->y);

    //Folio compuesto por mes, hora, dia, minutos, año y segundos
    $pdf->ezText('<b>' . xl ('Folio') . '</b>', 6);
    $pdf->ezText(('0') . date ('mHdiYs') . ('5'), 10);
    //$pdf->ezText(str_pad($p->patient->get_pubpid(), 10, "0", STR_PAD_LEFT), 10);
    $pdf->ezColumnsStop();
    if ($my_y < $pdf->y) {
        $pdf->ezSetY($my_y);
    }

    $pdf->ezText('');
    $pdf->line($pdf->ez['leftMargin'], $pdf->y, $pdf->ez['pageWidth'] - $pdf->ez['rightMargin'], $pdf->y);
    $pdf->ezText('<b>' . xl('Prescripción') . '</b>', 6);
    $pdf->ezText('', 10);
}

This type of modifications should be in a module to allow you to stay current with updates without the worry of reintroducing the custom code.
You can request us to add an event with a PR