Add Custom View Sql to bahmni-mart.json
As we know view is a virtual table based on the result-set of an SQL statement. All the existing views that we have in bahmni-mart.json are bundled with bahmni-mart.rpm file. But if we want to add a new view query to the bahmni-mart.json file, we have 2 ways to implement.
- Add direct query
- Give path of the query
1. Add Direct Query:
If we have simple view query to get executed on analytics database then we can directly add it in the bahmni-mart.json with the table name as show below
Once we add the above configuration in the mart file and run the bahmni-mart command, we will be able to see the corresponding table in the analytics database.
2. Give Path of the Query
If we have sql queries which is very big and can’t be included in the bahmni-mart.json file then it requires creating new sql file for it. Once we create/add sql file to bahmni instance in a specific path, we have to update the absolute path of sql query in the bahmni-mart.json. After that running the bahmni-mart will create the corresponding table in the analytics database.
In the above sample comfiguration, we have the sql file added in /home/bahmni/viewSql directory.
Points to note:
- This query must be a view query which will run on analytics tables.
- We can’t use these sql queries to run on openmrs tables to create the table in analytics database. For that we must add sql query to bahmni-mart and it will be bundled with the mart rpm.
Bahmni Wiki · CC BY-SA 4.0