Failed to Generate Bahmni Lab Reports

Tags: #<Tag:0x00007f0f1c358ab8>

Sorry am new to openbahmni, I tried to create simple query to get lab report but i keep get this error what may be the cause of this error?

org.postgresql.util.PSQLException: Can't use query methods that take a query string on a PreparedStatement

Hello @inno,

Can you provide more details about your Bahmni Lab Report?

  • Provide Report Configuration.

  • Share the SQL query of the report.

This is the query which throw that error…

SELECT test_section.name AS SECTION,
       test.name AS Test_Name,

  (SELECT COUNT(id)
   FROM test_result
   WHERE test_id=test.id
     AND cast(test_result.lastupdated AS DATE) BETWEEN '2020-07-01' AND '2020-07-18') AS Total
FROM test_section
LEFT JOIN test on test_section.id=test.test_section_id
WHERE
    (SELECT COUNT(id)
     FROM test_result
     WHERE test_id=test.id
       AND cast(test_result.lastupdated AS DATE) BETWEEN '2020-07-01' AND '2020-07-18')>0
ORDER BY SECTION ASC;

But whne i run this query direct to the database, I get result without any problem but when i generate it from bahmni i get that error, I do not know waht is the problem ?

@inno, The Above SQL query looks good. As I have asked you to share the Bahmni Lab Report configuration added in the report.json.

okey sorry, i did not understand at first

  "testSection": {
    "name": "Lab Test Section",
    "id": "bahmni.reports.labAndRadiology.testSection",
    "description": "Lab Test Section",
    "type": "ElisGeneric",
    "periodType": "Monthly",
    "category": "DHIS2",
    "url": "#/dashboard/deptreports?dept=labAndRadiology&reportId=testSection",
    "config": {
      "sqlPath": "/var/www/bahmni_config/openmrs/apps/reports/sql/lab/test_section.sql",
      "dept": "labAndRadiology"
    }
  },

Hey @inno,

For the Bahmni EMR reports the configuration should be like this in the report.json:

"testSection": {
"name": "Lab Test Section",
"type": "ElisGeneric",
"config": {
  "sqlPath": "/var/www/bahmni_config/openmrs/apps/reports/sql/lab/test_section.sql"
}

},

For more reference, Bahmni report configuration is here.