HFE: EncounterProviderAndRole tag filtering by UserRoles

Hello people,

In our project, we need to capture multiple EncounterProviders for one of the forms. While going through the references for HTMLFormEntry, we got to know we should use the encounterProviderAndRoleTag which allows to capture multiple providers and different roles in one encounter.

However, we figured out there is no way to filter the list of providers using UserRoles, instead there is a way to filter by providerRoles which comes from ProviderManagementModule. Any specific reason we had gone with a different model for filtering by roles?

Is there a way right now to use UserRole for getting the providers. Right now to make it work, we have to have an additional step, that maps every User => Provider to a provider role. We would like to avoid this step if possible.

Let us know your thoughts.

CC: @mksd @mogoodrich @dkayiwa

@rrameshbtech @sukreet @premnisha

1 Like

Semantically, I think this is correct, although I recognize that’s not helpful for your situation. An OpenMRS Role is really just a set of privileges. The ProviderRole provides a relationship between the provider and patient (A is the PCP of Patient B) and allows for certain other rich logic (C supervises A who supervises D).

More helpfully, I looks like the role attribute of encounterProvider filters based on Role rather than ProviderRole.

Yes, @ibacher is correct. The EncounterProviderAndRoles is a newer tag intended to replace the EncounterProvider role, which predates the introducation of the “Provider” and the “EncounterRole” concepts, and using ProviderRoles instead of “user” Roles is considered the best practice going forward for the recent Ian states.

That being said, as @ibacher mentioned I believe the legacy EncounterProvider can do what you need… but I believe only a single encounter provider tag is allowed per form (which you may have already discovered).

So, I’d support adding a new “userRoles” attribute to the EncounterProviderAndRoles tag to handle the legacy use case and to provide what you need if you’ve got the programming capacity… that being said, in the current model, in order to be associated with as an EncounterProvider on a form, so you will need to map each of your Users to a Provider regardless.

Take care, Mark


Whoops! I missed the “multiple provider” requirement!

For our post operative note (surgery), we capture this about the surgical team:

“other assistants” is free text, but the other providers are found in the database.


During an encounter, can a provider assume an encounter role that’s not any of his/her provider roles?

And if yes (which I suspect very strongly), then I guess things are just really flexible and that would mean that encounter roles and provider roles really operate at different levels? In such a way that provider roles just exist to describe the clinical organisation chart?

@mogoodrich Thanks for the detailed reply.

As of now, we create the Provider using the checkbox on Legacy UI User page, and it has been working for us so for. However if we add the map every provider to provider role it would mean for every user we should map them to an additional role.

We will discuss both options within our team

  • Add extra manual step to provider roles for providers.
  • Extend EncounterRoleAndProvider to filter by “userRoles”. My thoughts are it should be ignored if the providerRoles is present since that is the preferred one.

We would create an issue and raise a PR if we are going ahead with the second approach.


@ibacher, @mogoodrich

We are not able to try out ProviderManagement module as well. If we search with the provider and select one of the search result. It throws an error with screen below:

Please let us know if there is something missing in our installation. Below is the version of ProviderManagement module:

Provider Management Module	2.10.0
Openmrs Version: 2.3.0 Build b3ade0

@mogoodrich @ibacher @mksd

I was able to debug down the above problem. It is happening due to ProvideManagement still using 1.9.9 version of openmrs platform version.

The class NameSupport has been moved from org/openmrs/layout/web/name/NameSupport to org/openmrs/layout/name/NameSupport as part of one of the commits recently. I don’t think we can go ahead with provideRoles option unless this is upgraded to work with openmrs 2.x.x.

Please let us know your thoughts.

@mddubey why not just raise a pull request for the provider management module and load the appropriate class basing on the running openmrs platform? That is how we have dealt with supporting backwards compatibility, in modules.

@dkayiwa, if you mean to automatically override the import statement with different package name based on the running openmrs version, I could try that. However I will need a reference, since I have never done that before.

Though, is that the ideal way of doing it? I see a lot of other things would end up failing because they are not available. Like we have references to PatientSetService, PortletController which I couldn’t find in the latest openmrs.

Have you ever got a chance to look at these?



@dkayiwa! Sure I would have a look at that.

However, we might have to go ahead and extend the HTMLFormEntry tag since we would like to avoid the extra step where we have to map each provider to a provider role manually.

We wanted to have a look at the feasibility and the complexity of the problem. For that we were looking at the code, and looks like we will have to touch the EncounterProviderAndRoleTag and ProviderSearchController since there is an ajax query when we search for providers in autocomplete manner.

One question, which we have is how to retrieve providers for given role. From my understanding of the data-model, I can think of below:

  • Get the role.
  • Get all users with that role.
  • Each user will have a person.
  • Get any provider if associated with that person.(The user might not be a provider)
  • Use a set for providers because same user can have multiple roles to avoid duplicates.

Let us know if there is an easy way of doing it. CC: @ibacher @mogoodrich @mksd

@mddubey good catch with the error with Provider Management. For what’s it’s worth, we use Provider Management 2.10.0 with OpenMRS 2.3.0 without issue, but we don’t use that UI, so that’s why we never noticed it was broken.

We assign a roles to users/providers via the a custom UI Framework user management page… the Ref App user management page actually evolved out of this page. Does it not provide the ability to associate a role with a provider? If not, @cioan isn’t there some new provider management functionality we built, or am I misremembering? :slight_smile:

The idea of adding the userRoles attribute to EncounterProviderAndRoles makes sense to me.

Also, your logic to query for the provider list makes sense to me. I do think it would make sense to log an “warning” error if a single user has multiple providers because although the data model and API supports it, in the Ref App UI we generally only support a single provider per person, for what it’s worth.

Take care, Mark

1 Like


Thanks for your response. If there is a way it can be done on the RefApp User Management page, we can give that a try as well. As of now we cannot see anything on the page related to provider apart from the checkbox

Create a Provider account for this user

Do let us know if this is behind a toggle or something else.

Thank you

This makes sense to me too.

@mddubey FWIW, if making the existing UI of the provider management module behave as expected (that is the org/openmrs/layout/web/name/NameSupport problem) on platform 2.x is what you need, i can do it for you right away, if you created the ticket. :slight_smile:

Also, the old Account page in the EMR module allows for provider roles to be set (I haven’t looked at the code in years though):

This is functionality that we currently use in PIH EMR (though we’d like to get off it… there’s not much in the old EMR module we still use). It’s possible some of this could be ported to the Ref App account page.

Take care, Mark

@mogoodrich, @dkayiwa, @mksd, @ibacher

Thanks for helping out on this thread.

As of now, we are not thinking of this option, since it will introduce additional steps. I will create a card on ProviderModule Jira Project and can be taken later.

I will be creating another card on HTMLFormEntry project for introducing userroles and it will be picked up by our team.

1 Like

@dkayiwa, @mogoodrich, @mksd

Here are the cards:

Please let me know if is anything needs to be improved.