EncounterDiagnosis should be tied to the associated Visit and not the Patient

Hi all,

It so happens that when dealing with the EncounterDiagnoses widget(HFE tag), Diagnoses recorded in the past visits are also shown in the current visit. This sort of implies that the Diagnoses are tied to the Patient it’s self and not the visit. Do you think this was by design or a bug, if so any ideas or thoughts??

Steps to Reproduce this:

  1. Start a patient visit and record a Diagnosis using the encounter diagnoses widget(Within an htmlform)
  2. End the visit
  3. Start another visit and open the form, you will see diagnosis recorded in the past visit showup

cc: @mksd, @mogoodrich, @ssmusoke

This does not happen on the demo using the Visit Note. I happen to know that you’re testing this in another context, I would suggest to compare the two environments side by side to understand why you observe this in one and not the other.

Strangely this happens on the QA-RefApp server. This is still in the Reference Application environment.

This happens with the encounter diagnoses widget because it depends on this API call:

It’s true that this doesn’t happen in the demo. This is because the demo running Reference Application 2.9.0 which depends on core 2.1.4 unlike the QA server that runs I think the latest snapshot Reference Application -> core 2.3.0-SNAPSHOT .

The straightforward route of troubleshooting this bug is by comparing what changed in the two environments and the major change was with the core versions.

Diagnosis was introduced in core 2.2.0 and prior to that, I think the API leveraged around the Obs domain to record diagnoses. I think alot more work was going on within the EMR API module.


The EncounterDiagnosis widget is defined in the coreapps module and it has two defining elements ie. EncounterDiagnosesByObsElement and EncounterDiagnosesElement which are loaded conditionally. The former is loaded when running core version prior to 2.2.0 like in the demo and the latter is loaded when running 2.2.0 and above like in the QA server.

The difference that matters between the two implementations of the elements is how they retrieve what they understand as a Diagnosis.

The former(EncounterDiagnosesByObsElement) retrieves Diagnosis of the current visit :+1:

see:

While the latter(EncounterDiagnosesElement) gets all existing Diagnosis of the current patient which is the root cause of the bug :face_with_hand_over_mouth:. See:

cc: @mogoodrich

Opened ticket at:

Good find @samuel34!

At PIH, we are running OpenMRS Platform 2.3.x, but we haven’t had the chance to migrate our diagnoses to the new encounter_diagnosis table yet, so we are still storing them as Obs and therefore using the EncounterDiagnosisByObs widget, so we haven’t encountered this issue, but @samuel34’s analysis seems correct. Is there an easy way in the new model to select only those diagnoses defined in a the context of a specific visit?

Take care, Mark

Just to confirm encounter diagnoses are meant to be tied to the encounter. Condition List (aka Problem List) is meant to track conditions for a patient over time. Encounter diagnoses are used to specify those conditions (whether in the condition list or not) relevant to the specific encounter.

Good find, @samuel34!

2 Likes

Yeah sure. If I got you right this is the same approach I have used to face this.

Checkout PR: