Sending email with summary of daily admissions

Hi, There is a requirement from one of the existing implementation to have a email of summary of daily admissions sent to a group of doctors. This acts as reminder to senior doctors in case they missed seeing any patient. This is basically short information of new admission in the form of - Reg No/Name/Initial-Age-Gender-Short summary-probable diagnosis-admission location. Right now, one of the doctors responsible in IPD looks up through UI and sends across this email. However due to busy schedule, manual process, etc this is cumbersome and gets missed out. How can this be achieved with the current Bahmni features? One option is to have a custom report, that someone takes out daily and drafts email from that and sends across. Better than going through UI, but it’s still manual. The other option is to have something like mirthconnect installed with a database reader and email sender. I had spiked the database reader and email sending functionality in the past with mirthconnect for another usecase and it had worked. However this increases one more component (probably heavy) running on the server. Are there any other options?

1 Like

The OpenMRS Reporting module is running as part of Bahmni (though we don’t intentionally use it). The reporting module has support for an EmailProcessor, as well as for running reports on a schedule.

That would allow you to do this without installing another component.

You would have to do a bunch of obscure configuration via the reporting module’s UI (i.e. it can’t be done in your bahmni-config). Or it could be done in Java code as an OpenMRS add-on module that configures the reporting module as you want it. @mseaton could probably point you to a code example of this, and can probably tell you whether or not this requires code, or if it can be configured via the UI.

Thanks darius. I would wait to hear more from @mseaton and would like to try this out.

@arjun One of our implementations have a similar requirement… A dashboard for the hospital called “Indicator Dashboard”. The requirement is to provide a one-shot view of the hospital. It can contain things like Bed Occupancy, Admission status etc. I know @punith has got some requirements.

1 Like

Thanks @bharatak. i will catchup with Punith as well to see how he is planning to proceed with those requirements and with what timelines.

Hi @arjun.

To follow-up on @darius’ comment regarding the email processors in the reporting module, you can find some documentation on this feature on the OpenMRS Wiki

I would be interested in hearing how things go if you attempt to utilize this feature.

Thanks! Mike

Hi, I gave this a spin. I am not able to get the email to be sent through. I am using gmail smtp host. I am getting the “530 5.7.0 Must issue a STARTTLS command first” error. In advanced setting, i have set the global property “mail.smtp.starttls.enable” to true. However i still get this. Looking into the code, i don’t see this property being added to the session in getSession() of EmailReportProcessor. Would that be a bug or am i missing something?

It worked when i tried with an online smtp tester and so my settings (host, from, to, port,etc) seem to be fine.

I am using 0.10.6 openmrs reporting omod.

Any help appreciated.

@arjun, looks like you are right. I’m really surprised, because I’m the one who raised the ticket to get this global property added for this very reason (and we added use of it in the Sync module). But I guess it never made it into this class after all. Should be very easy to add - I’ll do that now.


For more updates, see ticket and associated commits here:

Thanks, Mike

Hi Mike, I was able to get this working with the fix you provided. I deployed it yesterday night on production as well. Will showcase to the users today and will wait for a few days to get some feedback. I am happy that we could cater to this request with a short turnaround time, without needing product development and without any extraneous component.

Also, I tried the openmrs reporting framework for the first time and i liked it.

Thanks much to you and @darius for the suggestion and help.

@arjun, that’s great to hear - thanks for the support! Let me know if it would be helpful for us to cut a new release at some point. It is easy enough to do.


Thanks @mseaton, i have informed the product development team. we would get back to you on this.
cc : @gsluthra @sdeepak

Thank you @mseaton We are planning to update the modules in bahmni distribution, will add this task to our Mingle, and take it on in next few weeks.

Hi @mseaton, The users have been benefitting from what has been done so far and have asked if it’s possible to show the output rows in alternate colours to make it more readable. Something like this

i was hoping to use TextTemplateRenderer but looking at this example and the renderer code, looks like it might work only with single row datasets. Is that understanding correct? If not, is there an example of a template somewhere which is for a similar need like this. I guess the template will need to have a loop? or is there a creative way to use the same.

@arjun looking at this code it looks like there are two different phases where things can be replaced. The first uses a TemplateEngine and this gives access to the entire reportData object. You’d just need to use whatever looping mechanism is supported by that template engine. I haven’t looked at the UI so I don’t know if this feature is accessible through there.

The other phase is that there’s a convenient shortcut where all single-row data set values can be used in a simpler replacement.

@arjun, not sure how I missed this question but apologies for not responding earlier. As @darius says, you can use a number of different template engines (Groovy is the main one I’ve seen used and comes out of the box, I think also Velocity and maybe Javascript are options) that can operate on the entire reportData object.

Also, I don’t think the replacement data that is available is limited to a single row - you can see in the implementation of getBaseReplacementData that it will include multi-row data by appending the row number to the end of the key. If there is only a single row in the dataset it will also make it available without the row num.

You can see some of this all in action with how we used these renderers to implement patient summaries in the patientsummary module.

Let me know if this helps at all.


No problem @mseaton. thanks to you and Darius for pointers. Looks like i somehow missed there is possibility for different template engines to use. I don’t have an instance in shape right now to try it out but will do so early next week and share how it goes.

Hi Mike and Darius, I tried it out last week and was easily able to get it working using groovy template. I could in fact just use the GroovyTemplate.txt from the tests in the code, with styling and dataset added.

I am also, planning to use it for another usecase - to send a periodic report to users about some key indicators as well as system usage (Number of patients seen, number of diagnosis entered, top diagnosis,etc). Even though important to keep up the adoption of the system, the local team wasn’t able to do it regularly due to lack of time. Now using this feature i would set it up. I am sure i will keep discovering more usecases where this feature could come in handy.



This looks like very interesting capability. Will you be documenting the steps and share any sample groovy script that you wrote? Either as a blog or a page on Bahmni wiki.



Pankaj, i was thinking that this thread itself would act as a blog and so was being a bit elaborate here :slight_smile: And the reporting feature is well documented on openmrs wiki. But if you think documenting the specific application with steps would be valuable i will do so.