Unable to Dispense in OPENEMR 6.1 and 7.0

Situation
Hello people, nice to be here. I did a recent installation of openEMR 6.1.0 I noticed that after setting up the pharmacy to dispense drugs and sell (actually the drugs are free) I’m unable to successfully dispense drugs. I keep getting an error message:

“Internal error: the referenced encounter no longer exists. 1 0”

So i installed the latest patch for 6.1.0 (1). Thesame error keeps occurring. The have inputted their drugs, entered lots. But the app does not dispense.

I deployed a version 6.0.0 as a training platform and version 6.1.0 as Production. Surprisingly, the training platform dispenses normally.
I have also upgrade to 7.0.0 and installed the first patch. Now the vitals form only display blood pressure after entry, most of the other fields do not appear in the summary.

Am i doing something wrong? Please any help on resolving this?

OpenEMR Version
I’m using OpenEMR version 6.1.0
PHP Version 7.4.30

Browser:
I’m using: Chrome

Operating System
I’m using: Ubuntu 18 as Server

Logs
Did you check the logs?
Was there anything pertinent in them?
Please paste them here (surround with three backticks (```) for readability.
You can also turn on User Debugging under Administration->Globals->Logging User Debugging Options=>All

Hi @techednig,

This is how you should go about this issue.

Disclaimer: I am on V6.1.0.

locate dispense_drug.php below

/openemr/interface/drugs/dispense_drug.php

On line 48, include below line of code

$encounter = $_SESSION[“encounter”];

On line 81, change 0 to $encounter, see below.

from

$sale_id = sellDrug($drug_id, $quantity, $fee, $pid, 0, $prescription_id, $today, $user);

to

$sale_id = sellDrug($drug_id, $quantity, $fee, $pid, $encounter, $prescription_id, $today, $user);

Save and retry.

The error,

Internal error: the referenced encounter no longer exists. 1 0

1 is the PID, whereas 0 is the encounter which has been initialized to 0. However, there’s no encounter ID of 0 in the database. So what you need to do is to get the current encounter and dispense the drug accordingly.

Hope this helps for you. Because it helped me.

2 Likes

Thank you KKappiah,

I tried your suggestion on version 6.1.0 and Version 7.0 (Patch 1). They both worked fine. So i want to believe your solution solves the dispense problem between version 6.1 and 7.0 (patch 1).

I discovered another challenge on the vitals form, i will open a new thread for it.

Thank you

1 Like