Need help displaying Obs from Encounter in Fragment

Hi Everyone,

I’ve been racking my brain over this. We ask a question on “informed consent” for one of our forms using the SimpleFormUI. This is working well. I’m building a fragment that displays all of the encounters for this particular form. I’m using the encounterService.getEncounters() function to get the list of encounters by uuid. Now that I have a list of encounters, I need to see if each encounter has a “yes” or “no” for the informed consent question which is stored as an obs within the encounter.

I don’t know how to access the list of observations in a particular encounter. I think the EMRAPI can do this, but can’t figure out which classes or methods to call in my controller. Do you have any ideas? Are there any examples of other people displaying an observation in a fragment?

Here’s my fragment controller:

Here’s the fragment .gsp:

Thanks for your help! Craig

Hi Craig,

In your controller you are not actually passing the list of encounterType to getEncounter() method and I suppose that is what you intended to do (One of the drawbacks of allowing null values).

Back to your question, If you want to get the obs you can iterate over the list of encounters and use the method that suits you from Encounter class to fetch the obs you want.

For example you can use this getObs() method to obtain a set of all non voided and non-grouped obs associated with a particular encounter: