Viewing list of Allergic Drugs on Drug Order Page


I am developing a Drug Order module. On the Order page, I want to view the list of Drugs that the Patient is Allergic to - The Allergic Drug info which is stored in Allergy table. Could anyone please guide me on how to get this.

Allergies allergies = patientService.getAllergies(patient);

1 Like

Have you looked at this?

Hi, Thank you! I did. but I am still unable to figure out the right steps to view the list of drugs patient is allergic to in the ‘Drug Order’ page. I am creating a new module - Drug Order. Here I want the list of Allergic drugs to be displayed

Hello, Could anyone please suggest the steps for being able to add a fragment that shows the list of drugs a patient is allergic to (Allergy UI), in my ‘under development’ Drug Order module.

I don’t understand what you’re asking.

You can fetch the patient’s allergies via the Java or REST API, and if you’re writing your own Drug Order module, it should be easy to display these on your existing page.

If you want to see how allergies are displayed in the reference application, here are the controller and view from the allergyui module.

You could even import this existing fragment (in a gsp page).

Hello, Sorry, I haven’t been able to figure out the right steps to display the list of ‘Drug Allergies’ in my Drug Order module. This is what I have - The Dashboard page on which I want to display the fragment containing the allergic drugs - drugAllergies Fragment

I am getting an argument mismatch error here -

public class DrugAllergiesFragmentController { public void controller(FragmentModel model, @FragmentParam(“patientId”) Patient patient, @SpringBean(“allergyService”) PatientService patientService) {

	model.addAttribute("allergies", patientService.getAllergies(patient));


In my Dashboard page -

${ ui.includeFragment(“drugOrders”, “drugAllergies”, [ patientId: ]) }

In drugAllergies.gsp Fragment -

<% allergies.each { allergy -> %> ${ allergy.allergen } <% } %>

What version of the OpenMRS platform are you running this against?

-Darius (by phone)

OpenMRS 2.3

I don’t see anything obviously wrong with the code you have pasted.

If you’re getting an error, then share the specific error details.

Thank you Darius and Daniel. I managed to get the allergic drugs on my dashboard page for Drug Orders module. I was attempting to display that in a separate fragment, now showing them on the page.