Skip to content

Commit

Permalink
Merge pull request #66 from OpenLMIS-Angola/OAM-295
Browse files Browse the repository at this point in the history
OAM-295: The name of Muncipio in the PDF report is displayed as Institution name instead of said muncipality.
  • Loading branch information
olewandowski1 authored Aug 8, 2024
2 parents c64bb9e + 1d178f0 commit 22e5f54
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
29 changes: 27 additions & 2 deletions reports/angola_non_reporting_facilities.jrxml
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,37 @@ WITH RECURSIVE findChildZones AS (
SELECT * FROM referencedata.geographic_zones WHERE name = $P{district}::varchar
UNION ALL
SELECT referencedata.geographic_zones.* FROM referencedata.geographic_zones JOIN findChildZones ON findChildZones.id = referencedata.geographic_zones.parentId
),
facilityWithParentZone AS (
SELECT
facilities.id AS facility_id,
COALESCE(parent_zones.name, zones.name) AS parentZone
FROM
referencedata.facilities AS facilities
JOIN referencedata.geographic_zones AS zones ON facilities.geographicZoneId = zones.id
LEFT JOIN referencedata.geographic_zones AS parent_zones ON zones.parentId = parent_zones.id
JOIN referencedata.geographic_levels AS levels ON zones.levelid = levels.id
WHERE
levels.levelnumber = 4
),
facilityWithProvince AS (
SELECT
facilities.id AS facility_id,
COALESCE(grandparent_zones.name, parent_zones.name, zones.name) AS provinceName
FROM
referencedata.facilities AS facilities
JOIN referencedata.geographic_zones AS zones ON facilities.geographicZoneId = zones.id
LEFT JOIN referencedata.geographic_zones AS parent_zones ON zones.parentId = parent_zones.id
LEFT JOIN referencedata.geographic_zones AS grandparent_zones ON parent_zones.parentId = grandparent_zones.id
JOIN referencedata.geographic_levels AS levels ON zones.levelid = levels.id
)
SELECT
referencedata.processing_periods.name AS period,
referencedata.facilities.code AS code,
referencedata.facilities.name AS facility,
referencedata.facility_types.name AS type,
referencedata.geographic_zones.name AS zone,
provincia.name AS provincia,
facilityWithParentZone.parentZone AS zone,
facilityWithProvince.provinceName AS provincia,
program.name as programName
FROM referencedata.facilities
JOIN referencedata.geographic_zones ON
Expand All @@ -171,6 +194,8 @@ FROM referencedata.facilities
rgps.requisitiongroupid = rg.id AND rgps.programid = program.id
JOIN referencedata.supported_programs sp ON
sp.programid = program.id AND sp.facilityid = referencedata.facilities.id
JOIN facilityWithParentZone ON facilities.id = facilityWithParentZone.facility_id
JOIN facilityWithProvince ON facilities.id = facilityWithProvince.facility_id
LEFT JOIN referencedata.facility_types ON
referencedata.facilities.typeid = referencedata.facility_types.id
LEFT JOIN referencedata.processing_periods ON
Expand Down
17 changes: 15 additions & 2 deletions reports/angola_reporting_rate_report.jrxml
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,21 @@ ORDER BY referencedata.processing_periods.startdate]]>
),
findLastPeriods AS (
SELECT * FROM referencedata.processing_periods WHERE startdate <= (SELECT startdate FROM referencedata.processing_periods WHERE name = $P{Period}::varchar) ORDER BY startdate DESC LIMIT 1
)
),
facilityWithParentZone AS (
SELECT
facilities.id AS facility_id,
COALESCE(parent_zones.name, zones.name) AS parentZone
FROM
referencedata.facilities AS facilities
JOIN referencedata.geographic_zones AS zones ON facilities.geographicZoneId = zones.id
LEFT JOIN referencedata.geographic_zones AS parent_zones ON zones.parentId = parent_zones.id
JOIN referencedata.geographic_levels AS levels ON zones.levelid = levels.id
WHERE
levels.levelnumber = 4
),
SELECT
referencedata.geographic_zones.name AS geographiczonename,
facilityWithParentZone.parentZone AS geographiczonename,
COUNT(CASE WHEN status_change.createddate IS NOT NULL THEN 1 END) AS completed,
COUNT(CASE WHEN referencedata.processing_periods.enddate + (CASE WHEN $P{DueDays}::varchar IS NULL THEN 15 ELSE $P{DueDays}::int END) + 1 >= status_change.createddate THEN 1 END) AS ontime,
COUNT(CASE WHEN status_change.createddate IS NULL THEN 1 END) AS missed,
Expand All @@ -201,6 +213,7 @@ FROM referencedata.facilities
rgps.requisitiongroupid = rg.id AND rgps.programid = program.id
JOIN referencedata.supported_programs sp ON
sp.programid = program.id AND sp.facilityid = referencedata.facilities.id
JOIN facilityWithParentZone ON facilities.id = facilityWithParentZone.facility_id
LEFT JOIN referencedata.processing_periods ON
referencedata.processing_periods.id IN (SELECT id FROM findLastPeriods)
LEFT JOIN requisition.requisitions ON
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 22e5f54

Please sign in to comment.