Reports
The term "Generic Reports" has been dropped in favour of just "Reports". This feature also supersedes the older "Canned Reports" feature. Note that both - Reports and Canned Reports don't make use of any specific SQL configuration, but instead use json based entity configuration to generate reports. You can see samples for report.json here in Github (default-config): https://github.com/Bahmni/default-config/tree/master/openmrs/apps/reports.
On an installed CentOS box, or Vagrant you can find the Bahmni report config files in this location: /etc/bahmni-web/bahmni_config/openmrs/apps/reports
Purpose and Benefits
Canned and Custom Reports have their limitations. An implementer needs to know the OpenMRS data model and Custom SQL to extract the data for custom reports. In response to customer requests, developers have to repeatedly create custom reports by duplicating the SQL from a similar report, thus increasing the maintenance complexity.
To solve this, Bahmni has introduced entity based reports for various entities in OpenMRS, for example: Observations, Visits and Programs etc. These reports allow an implementer to extract data from the system for each entity, hence Bahmni has a report for each. These reports provide options to include related fields and to apply various filters.
type | Name | ||
|---|---|---|---|
| 1 | visits | Visit based reports | |
| 2 | observations | Observations recorded for patients | |
| 3 | forms | Observation Form report | |
| 4 | formBuilder | Observations captured in specific form (created via Form Builder) | |
| 5 | programs | Data for patients enrolled in particular Program | |
| 6 | aggregation | To show aggregate data (like a pivot table) on Observations | |
| 7 | concatenated | Concatenates multiple "reports" into one report with multiple tabs for each report | |
| 8 | labOrders | Lab Orders/results for patient | |
| 9 | 9 | fhirTSLookupDiagnosis | Diagnosis count report based on hierarchy offered by FHIR based terminology server i.e. Snowstorm |
Info
For details of each report type, see documentation below.
Privilege based access to reports
From Bahmni 0.93 version onwards, you can have privilege based access to any report.
The configuration parameter "requiredPrivilege" determines whether a logged in user can run a particular report. Note, this is in addition to the mandatory "app:reports" privilege that must be assigned to have users access to the reporting module. In sample configuration here (in your server setup location /var/www/bahmni_config/openmrs/apps/reports/reports.json), you may notice that the "requiredPrivilege" is mentioned as "app:reports" - you should change it and assign specific privilege to the report definition. You can define custom "privileges" and group it under appropriate role (or create new role) to be assigned to a user.
Types of Reports
1. Visits Report
This feature allows the implementer to configure a customer-specific way to extract visit information. Using this report, filter(s) can be applied and a specific set of fields can be configured to appear in the output.
The following fields appear by default in the output.
Patient Identifier
Patient Name (First Name + Last Name)
Age
Birthdate
Gender
Patient Created Date
Visit type
Date started
Date stopped
Date Of Admission
Date Of Discharge
New patient visit (When patient created and visit started same day then that visit considered)
Key | Description | Required | Default |
|---|---|---|---|
nameOfReport | Unique key to identify the report | Yes |
|
name | Report name to be shown on report | Yes |
|
type | Type of report | Yes | It has to be "visits" |
config | The section to configure what is needed in the report | No |
|
forDataAnalysis | Fetches the patient_id and visit_id in the report | No | False |
patientAttributes | Fetches patient attributes along with the mandatory fields | No |
|
visitAttributes | Fetches visit attributes along with the mandatory fields | No |
|
patientAddresses | Fetches patient address along with the mandatory fields | No |
|
applyDateRangeFor | Configures the field which we have to apply the date range for (visitStopDate | visitStartDate | dateOfAdmission | dateOfDischarge) | No | visitStartDate |
visitTypesToFilter | Filters the visits by its type | No | All visit types |
excludeColumns | Excludes the columns from output. | No | Includes all columns. |
additionalPatientIdentifiers | Displays additional identifiers in the report | No | No additional patient identifiers |
ageGroupName | Name of the age group to show in report. Age group configurations can be inserted into the reference table "reporting_age_group" | No | No age group |
preferredColumns | Order of the columns to be displayed in the output report Need not mention all the columns in the config. Configured columns will be given precedence and shown first followed by all the other remaining columns in default order | No | Default order of the columns for the report. sample configuration "preferredColumns": ["Patient Name","Birth Date","Age"]
|
sortBy | To sort the reports output in ascending/descending order based on the configuration. Columns that are not present in the output of the report should not be configured. Default behaviour If just column is configured, not the sortOrder , then default sortOrder is ascending (asc). Allowed values for "sortOrder" For key "sortOrder", "asc" or "desc" are allowed values. Configured values are case insensitive. | No | Default output for the report. sample configuration "sortBy" : [{"column" : "BirthDate", "sortOrder" : "desc"}] |
Sample Report
2. Observations Report
This feature allows the implementer to configure a way to extract observation information. Using this report, filter(s) can be applied and a specific set of fields can be configured to appear in the output.
The following fields appear by default in the output.
Patient Identifier
Patient Name (First Name + Last Name)
Age
Birthdate
Gender
Location Name
Concept Name (If encounterPerRow is false)
Observation Value (If encounterPerRow is false)
Observation datetime (If encounterPerRow is false)
Parent Concept (If encounterPerRow is false)
Program Enrollment Date
Program End Date
Patient Created Date
Key | Possible Values | Description | Required | Default |
|---|---|---|---|---|
nameOfReport | Any string | Unique key to identify the report | Yes |
|
name | Any String | Report name to be shown on report | Yes |
|
type |
| Type of the report | Yes | "It has to be observations" |
config |
| The section to configure what you need in the report | No |
|
patientAttributes | Any patient attribute types | Fetches patient attributes and mandatory fields | No |
|
patientAddresses | Any patient address fields | Fetches patient address and mandatory fields | No |
|
visitAttributes | Any visit attribute types | Fetches visit attributes and mandatory fields | No |
|
showVisitInfo | true / false | Fetches visit information and mandatory fields. It fetches visit type, visit start date, visit stop date. | No | False |
showProvider
| true / false | Fetches providers of individual observation. NOTE: Report doesn't show provider name if encounterPerRow is true. | No | False |
conceptNamesToFilter | Any FULLY_SPECIFIED concept name | Filters observation by any concepts/template/forms. It should be a FULLY_SPECIFIED concept name | Yes/No | All observations within date range if encounterPerRow is false No observations if encounterPerRow is true |
conceptValuesToFilter | Any value | Filters observation by any values like coded, range, text. (“underWeight”, “Normal”, “10..100”, “..100”). Format for numeric ranges : - "10..100": A range from 10 to 100 inclusive - "..100": Maximum value 100 inclusive - "10.." Minimum value of 10 inclusive | Yes/No | All observations within date range if encounterPerRow is false No observations if encounterPerRow is true
|
conceptClassesToFilter | Any concept class | Filters observation by any concept classes like Drug, LabTest etc.. | Yes/No | Doesn't filter. Gives all observation of concepts configured of any class. |
locationTagsToFilter | Any location tag | Filters observations by locations. | No | All locations' data. |
applyDateRangeFor | visitStopDate / visitStartDate / programDate / obsCreatedDate / obsDate | Configures the field which we have to apply the date range for. | No | obsDate |
encounterPerRow | true / false | Fetches one encounter per row. ConceptName will be column and value will be row. If a concept is captured multiple times in an encounter it will appear comma separated. | No | False |
forDataAnalysis | true / false | Fetches database ids like patient_id, concept_id, observation_id etc. for purpose of analysis. | No | False |
programsToFilter | any program name | Filters observations by programs | No |
|
visitTypesToFilter | any visit type | Filters the visits by its type | No | All visit types |
excludeColumns | any column names | Excludes the columns from output. | No | Doesn't exclude any columns. |
additionalPatientIdentifiers | Any additional patient identifier type | Displays additional identifiers in the report | No | Doesn't display additional patient identifiers |
ignoreEmptyValues | true / false | Ignores rows with no observation value. This config is not applicable when encounterPerRow is true | No | false |
conceptNameDisplayFormat | shortNamePreferred /fullySpecifiedName /fullySpecifiedName (shortName) | Displays the format of concept name on the report. shortNamePreferred displays the Concept Short Name if available, else the Fully Specified Name. Note: This option is currently only available for observation reports. | No | fullySpecifiedName(shortName) |
ageGroupName | Name of age group | Age group to be displayed in the report | No | Doesn't show age group |
preferredColumns | List of column names | Order of the columns to be displayed in the output report Need not mention all the columns in the config. Configured columns will be given precedence and shown first followed by all the other remaining columns in default order | No | Default order of the columns for the report. sample configuration preferredColumns: ["Patient Name","Birth Date","Age"] |
sortBy | List of objects | To sort the reports output in ascending/descending order based on the configuration. Columns that are not present in the output of the report should not be configured. Sorting on Observation value may not work as expected because the value might have mixed data types. Default behaviour If just column is configured, not the sortOrder , then default sortOrder is ascending (asc). Allowed values for "sortOrder" For key "sortOrder", "asc" or "desc" are allowed values. Configured values are case insensitive.
| No | Default output for the report. sample configuration "sortBy" : [{"column" : "BirthDate", "sortOrder" : "desc"}]
|
Report with one observation per row
Report with one encounter per row