ObsAcrossEncounters widget - Coalesce multiple answers recorded for the same question

Hello to you all,

It was noticed that whenever we have multiple answers recorded for the same question on an encounter , obsacrossencounters widgets do not show all the answers.



When using obsacrossencounters widget to see the above obs on the specific encounter:


So maybe we could make some changes in order to coalesce multiple answers recorded for the same answer in obsacrossencounters. Something like below:


What your thoughts about this?

Thank you.

CC: @mksd @dkayiwa @mogoodrich @bistenes

1 Like

Looks like the documentation says " If an encounter has multiple obs with the given concept then they will be displayed in separate rows"


So either this is a bug or the documentation is incorrect…

Not sure about the initial reasoning behind displaying in multiple rows, but I do think I like the idea of coaleascing into a single row better…

@ssmusoke I forget if this is a widget your team uses? If so, do you have any insight?

Take care, Mark


If an encounter has multiple obs with the given concept then they will be displayed in separate rows.

But then what happens if there multiple answers recorded for several questions during the same encounter, eg:

(Q1) Condition

  • (A1) Asthma
  • (A2) Obesity

(Q2) Allergy

  • (A1) Nuts
  • (A2) Pollen

Then what? This?

Date Condition Allergy
04.May.2021 Asthma Pollen
04.May.2021 Asthma Nuts
04.May.2021 Obesity Pollen
04.May.2021 Obesity Nuts

Or this?

Date Condition Allergy
04.May.2021 Asthma
04.May.2021 Obesity
04.May.2021 Pollen
04.May.2021 Nuts

What @ifernandes suggests is that this gets coalesced as this:

Date Condition Allergy
04.May.2021 Asthma, Obesity Pollen, Nuts
1 Like

Yes, I think the current behavior is well-defined only for

  1. multiple questions that can have one answer each—in this case we get one row per encounter
  2. an obsgroup that can appear multiple times—in this case we get one row per obsgroup

I didn’t actually know that it was allowed to have the same question multiple times in the same encounter if that question was not wrapped in an obsgroup. If that’s legal, then we should write test cases for it and make it behave well, while not breaking the existing test cases.

The trick will be to differentiate case (2) above from this new case (3) one or more questions that can appear multiple times. I think we still want obsgroups in separate rows as they are currently. But I like your solution for the use case you mention, @ifernandes .

1 Like


Thank you for your insights.

@bistenes , about current behavior on point 2., I tested an obsacrossencounters using obsgroup but I got empty values on the widget.



Using the above 2 concepts (Other Question and Obsgroup) in obsacrossencounter json config:


Maybe you are referring to obsgroup used on Latest Obs For Concept List, correct?

So, should I open an improvement on Openmrs JIRA to enhance obsacrossencounters with multiple answers coalesce on the same question? Thanks!


We use this widget, however we have not had to use it with ObsGroups

IMO this is correct since the concept is grouped once by encounter then by the obs

@ssmusoke those are not obs groups, those are just multiple different answers to the same question.

@mksd Thanks for the clarification

While we have not used the multiple obs answers, IMO they should appear in a single row as suggested by @bistenes - not sure how it works at the moment

Interesting @ifernandes ! Yes, I might be mixing those up. What’s the behavior of the obsacrossencounter widget when configured to only display the obsgroup, and not “Other Question”?

Hello @bistenes . When configured to only diplay the obsgroup , I have empty field:


Not sure if it’s expected to have any data. To be honest I thought that obsgroup concepts could only be used on latestobsforconceptlist.

Thanks for helping understand the normal behavior here :wink:

I have opened an Improvement on openmrs jira:

1 Like

For obsgroup display, looks like there’s exactly one unit test: “it should show separate obs groups on separate lines.” The test demonstrates usage with obs groups—the concepts specified are not grouping constructs themselves, but rather are contained within constructs. See the description at the top of the test file of how the mock data is structured.

So what this test says is that given two concepts A and B, where A is in obsgroup C and B is in obsgroup D, and given one obs for A and two obs for B, all in the same encounter, the widget will display two separate rows. I think we want to preserve this behavior.

1 Like

Just to follow up on this, we did a small test by configuring an ObsAcrossEncounters widget with concepts contained within different obsgroups.

On the left (image below), we have the form with 4 obsgroups (one per line): Services, Transport, Accommodation and Food. Transport group contains 3 concepts, the others contain 2 (as visible on the cells).

On the right, we have the resulting widget. As expected, the behaviour is the one described by @bistenes , groups are separated by rows.

Just one thing to point out: with this configuration, by looking at the widget, we don’t know which line corresponds to which group.


Thanks @icrc.psousa, that was a very clearly laid out example.

Also in the case above, all constructs are basically of the same nature (with actually the same members), so, even though the widget does not let us distinguish which row is which group exactly, things still roughly make sense and display coherently.

But if those constructs had been more foreign, with different sets of members, then this widget would not make much sense anymore. Probably all this should be better documented in the wiki…

@icrc.psousa Would it not make sense to add an obs column for the obs group so that you can identify it, in this case the Services/Transport/Accomodation/Food values

The reality is not to depend on the order of the data entered since it cannot be predicted