Read about OpenEMR's Response to the COVID-19 Pandemic at https://www.open-emr.org/covid19/

Need help getting drug generic name into prescription

Using OpenEMR v5.0.1 (7) with Windows 10

Hello everyone. Now that prescriptions are allowed for telemedicine in India I’m trying to format the OpenEMR prescription to local guidelines. I’m presently stuck at getting drug generic name into the prescription.

I’ve reached this far
Drug generic name is in drug_templates table in ‘selector’ field
Same is captured in C_Prescription.Class.php as ‘t.selector’ on line 49

    $res = sqlStatement("SELECT d.name, d.ndc_number, d.form, d.size, " .
                    "d.unit, d.route, d.substitute, t.drug_id, t.selector, t.dosage, " .       
                    "t.period, t.quantity, t.refills, d.drug_code " .
                    "FROM drug_templates AS t, drugs AS d WHERE " .
                    "d.drug_id = t.drug_id ORDER BY t.selector");

It is not assigned to $drug_attributes and then I’m unable to add it without it throwing a blank window when attempting to print to pdf

while ($row = sqlFetchArray($res)) {
                $tmp_output = $row['selector'];
                if ($row['ndc_number']) {
                    $tmp_output .= ' [' . $row['ndc_number'] . ']';
                }

                $drug_array_values[] = $row['drug_id'];
                $drug_array_output[] = $tmp_output;
                if ($drug_attributes) {
                    $drug_attributes .= ',';
                }

                $drug_attributes .=    "['"  .
                    attr($row['name'])       . "',"  . //  0
                    attr($row['form'])       . ",'"  . //  1
                    attr($row['dosage'])     . "','" . //  2
                    attr($row['size'])       . "',"  . //  3
                    attr($row['unit'])       . ","   . //  4
                    attr($row['route'])      . ","   . //  5
                    attr($row['period'])     . ","   . //  6
                    attr($row['substitute']) . ","   . //  7
                    attr($row['quantity'])   . ","   . //  8
                    attr($row['refills'])    . ","   . //  9
                    attr($row['quantity'])   . ","   . //  10 quantity per_refill
                    attr($row['drug_code'])  . "]";    //  11 rxnorm drug code
            }

I have managed to alter the function ‘get_prescription_body_text()’ (line541)
to include the ‘drug_id’ number. But all my efforts to similiarly include ‘selector’ result in a blank window. I’ve reproduced the function as I have altered it below and its generating the prescription pdf. What I need is help to get ‘selector’ to show in the place where I’ve managed to put ‘get_drug_id()’. Substituting it is not working.

function get_prescription_body_text($p)
    {
        $body = "<b>-   " . text($p->form_array[$p->get_form()]) . ' ' . text($p->get_drug()) . ' (' . text($p->get_drug_id()) . ') ' . text($p->get_size()) . text($p->get_unit_display());
        /* if ($p->get_form()) {
            $body .= ' [' . text($p->form_array[$p->get_form()]) . "]";
        }
		*/
        $body .= '</b>' .     // <i>" .
            // text($p->substitute_array[$p->get_substitute()]) . "</i>\n" .
            
            // '<b>' . xlt('Sig') . ':</b> ' . text($p->get_dosage()) . ' ' . text($p->form_array[$p->get_form()]) . ' ' .
            // text($p->route_array[$p->get_route()]) . 
			' ' . text($p->interval_array[$p->get_interval()]) . 
			' x <b>' .  text($p->get_quantity()) . '</b>' . xlt('days') ;
        
		if ($p->get_refills() > 0) {
            $body .= "\n<b>" . xlt('Refills') . ":</b> <u>" .  text($p->get_refills());
            if ($p->get_per_refill()) {
                $body .= " " . xlt('of quantity') . " " . text($p->get_per_refill());
            }

            $body .= "</u>\n";
		
        } /* else {
            $body .= "\n<b>" . xlt('Refills') . ":</b> <u>0 (" . xlt('Zero') . ")</u>\n";
        }
		*/
        $note = $p->get_note();
        if ($note != '') {
            $body .= "\n(" . text($note) . ")\n";
        }
		
        return $body;
    }

Any help would be appreciated. Thanks in advance.

If it’s just a few prescriptions you use a lot you can add them using the medication list editor. Go to administration -> forms -> lists. In the dropbox search for medication issue list. Then just add the most commonly used drugs.

Are you using the RxNorm dataset? You’ll need to create an account with UMLS to download it for use in OpenEMR. Go to Administration -> coding -> external data loads, expand RxNorm and follow the instructions displayed by clicking the question mark?

Thanks Rachel. I’m using Inventory > Management where I’ve already added the drug brand and generic names . C_Prescription.Class.php prints a prescription with the drug brand name only. India rules require the drug generic name also. The drug generic name is in drug_templates.selector table. My difficulty is with extracting it from there.

Again for RxNorm the drug code only is extracted to the drugs table, the name is not so it might not help.

C_xxx populates class defined in library/classes e.g. prescription class. That class is passed to the function you are changing as $p. To get selector information, you will need to add method get_selector that returns value from drug_array_output passed to constructor of that prescription object.

Best.

Thank you. I added a variable to get selector for group_id in the function and print what I needed. I was unable to implement what you suggested right now as I need more time to fully understand how it works.