How can i make a report for an observation form in bahmni ??

hi, I want to add a new report for ANC observation form in the report application. How can i achieve this ??

Please check this wiki page for Observation Form Report

@ramashish i followed the same wiki page for it. But i’m getting an error like " HTTP Status 500 - Incorrect Configuration Column that you have configured in sortBy is either not present in output of the report or it is invalid column" . In the wiki page it says sortBy is not mandatory. Please help me to resolve this

Unless, you provide more information, this is just guessing! but …

  1. What type of Form was that? Forms 1 (concept set based) or Forms 2?
  2. If Forms2, have you configured it right? In the config, the “type” must be => “type”: “formBuilder”
  3. Check in bahmni-reports log: /var/log/bahmni-reports/bahmni-reports.log

@angshuonline Thanks for the reply.

I used ANC Form which is there out of box already. I hope it is a concept set based form because all elements are there in concept dictionary.

i’m not able to print report for this form even i am not able to print “Test Forms Report” which is already there in the reports app. it is also showing same error.

here the report log:

2019-08-01 23:57:38,091 ERROR [bahmnireports][org.bahmni.reports.web.MainReportController] Error running report
org.quartz.impl.jdbcjobstore.InvalidConfigurationException: Column that you have configured in sortBy is either not present in output of the report or it is invalid column
        at org.bahmni.reports.util.SqlUtil.executeSqlWithStoredProc(
        at org.bahmni.reports.dao.impl.GenericObservationFormDaoImpl.getResultSet(
        at org.bahmni.reports.web.ReportGenerator.invoke(
        at org.bahmni.reports.web.MainReportController.getReport(
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(
        at org.springframework.web.servlet.DispatcherServlet.doService(
        at org.springframework.web.servlet.FrameworkServlet.processRequest(
        at org.springframework.web.servlet.FrameworkServlet.doGet(
        at javax.servlet.http.HttpServlet.service(
        at org.springframework.web.servlet.FrameworkServlet.service(
        at javax.servlet.http.HttpServlet.service(
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(
        at org.apache.catalina.core.StandardWrapperValve.invoke(
        at org.apache.catalina.core.StandardContextValve.invoke(
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
        at org.apache.catalina.core.StandardHostValve.invoke(
        at org.apache.catalina.valves.ErrorReportValve.invoke(
        at org.apache.catalina.core.StandardEngineValve.invoke(
        at org.apache.catalina.connector.CoyoteAdapter.service(
        at org.apache.coyote.http11.AbstractHttp11Processor.process(
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
        at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$ Source)
        at org.apache.tomcat.util.threads.TaskThread$
        at Source)

Have you checked your report definition? location: /var/www/bahmni_config/openmrs/apps/reports/reports.json Are you sure that all the fields mentioned are present in the forms?

Also, don’t just start from “Default” setup, the “Default” is example means to get people started! If you edit things on metadata, you must ensure that you edit things for “default” configuration as well.


Yes i have added report definition on /var/www/bahmni_config/openmrs/apps/reports/reports.json only and fields are there in the form. i rechecked again

Please check “obsParent” function/procedure is present in openmrs database. If not found please add “obsParent” function by running the bellow query & try again. It should work.

CREATE DEFINER=`openmrs-user`@`localhost` FUNCTION `obsParent`(obsid int) RETURNS int(11)
    DECLARE parent_id int;
    DECLARE conceptid int;
        SET parent_id = NULL;
        select obs_group_id into parent_id from obs where obs_id = obsid;
        IF parent_id IS NULL THEN
            LEAVE sloop;
        END IF;
        SET obsid = parent_id;
        ITERATE sloop;
    select concept_id into conceptid from obs where obs_id = obsid;
    RETURN conceptid;
END ;;

Please try it & if any problem arise again please let me know.


@rakib.hasan Thanks a lot for the help. I was stuck with this… It worked for me.