Closed nupoorkhandelwal closed 8 months ago
New Report :
Old Report :
@Dinesh2019 I used the following script to QA, you can verify the same.
with needs_assesment_enc as (
select
enc.individual_id ind_id,
enc.id,
enc.program_enrolment_id enl_id,
null "Visit cancel reason",
enc.encounter_date_time ,
enc.cancel_date_time ,
enc.max_visit_date_time ,
'Monthly needs assessment' encounter_type,
enc.address_id
from ihmp.individual_eligible_couple_needs_assessment enc
where enc.is_voided is false
and enc.earliest_visit_date_time between '01-01-2023' and '02-10-2024'
union all
select
enc.individual_id ind_id,
enc.id,
enc.program_enrolment_id enl_id,
enc."Visit cancel reason",
enc.encounter_date_time ,
enc.cancel_date_time ,
enc.max_visit_date_time ,
'Monthly needs assessment' encounter_type,
enc.address_id
from ihmp.individual_eligible_couple_needs_assessment_cancel enc
where enc.is_voided is false
and enc.earliest_visit_date_time between '01-01-2023' and '02-10-2024'
), eligible_couple_program as (
select
i.id ind_id,
enl.id enl_id,
i.address_id add_id
from ihmp.individual i
inner join ihmp.individual_eligible_couple enl on enl.individual_id = i.id
where i.is_voided is false
and enl.is_voided is false
and enl.program_exit_date_time is null
)
select
count(distinct enc.id) "Scheduled",
count(*) filter (where enc.encounter_date_time::date between '01-01-2023' and '02-10-2024') "Completed",
count(*) filter (where enc.encounter_date_time isnull and enc.max_visit_date_time < '02-10-2024' and enc.cancel_date_time is null ) "Overdue",
count(*) filter (where enc.cancel_date_time notnull) "Cancelled",
count(*) filter (where enc.cancel_date_time notnull and enc."Visit cancel reason" = 'Absent' ) "Absent",
count(*) filter (where enc.cancel_date_time notnull and enc."Visit cancel reason" = 'Other' ) "Other",
count(*) filter (where enc.cancel_date_time notnull and enc."Visit cancel reason" = 'Away from village' ) "Away from village"
from needs_assesment_enc enc
join eligible_couple_program enl on enc.enl_id = enl.enl_id
join ihmp.address on address.id = enl.add_id
join virtual_catchment_address_mapping_table cam on cam.addresslevel_id = address.id
join catchment on catchment.id = cam.catchment_id
where 1=1
and catchment."name" = 'Akhadwada 1';
@Dinesh2019 you can maybe get this script reviewed by nupoor as well to be double sure.
Existing report link
https://reporting.avniproject.org/question/535-encounter-type-attendance-and-cancellation-report
Support ticket
https://avni.freshdesk.com/a/tickets/3459
Context
Earlier we had worked on migrating IHMP reports to ETL, but had not moved this particular report as it uses all the program encounters and it was working fine earlier. But seems over time it has become non-responsive. We will have to move to move it to ETL so that client can use it.
The old report still work for a very small date filters
Tech Approach