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

Tags: #<Tag:0x00007f8c9047b5c0> #<Tag:0x00007f8c9047b480>

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(SqlUtil.java:79)
        at org.bahmni.reports.dao.impl.GenericObservationFormDaoImpl.getResultSet(GenericObservationFormDaoImpl.java:98)
        at org.bahmni.reports.template.GenericObservationFormReportTemplate.build(GenericObservationFormReportTemplate.java:86)
        at org.bahmni.reports.util.BahmniReportUtil.build(BahmniReportUtil.java:33)
        at org.bahmni.reports.web.ReportGenerator.invoke(ReportGenerator.java:49)
        at org.bahmni.reports.web.MainReportController.getReport(MainReportController.java:53)
        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.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:618)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106)
        at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:534)
        at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081)
        at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658)
        at org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566)
        at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
        at java.lang.Thread.run(Unknown 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.

@angshuonline

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.

DELIMITER ;;
CREATE DEFINER=`openmrs-user`@`localhost` FUNCTION `obsParent`(obsid int) RETURNS int(11)
    DETERMINISTIC
BEGIN
    DECLARE parent_id int;
    DECLARE conceptid int;
    sloop:LOOP
        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;
    END LOOP;
    select concept_id into conceptid from obs where obs_id = obsid;
    RETURN conceptid;
END ;;
DELIMITER ;

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

1 Like

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