avniproject / ihmp

0 stars 0 forks source link

add indicators in MPR #68

Closed sachsk closed 1 year ago

sachsk commented 1 year ago

FD:https://avni.freshdesk.com/a/tickets/2934

In MPR needs assessment add these tow indicator

### Ticket has been re-opened, same changes need to be done in the Combined MPR (Child and Needs assessment) report as well.

Dinesh2019 commented 1 year ago

Generic query used for testing with all_filtered_applied as (select individual.id ind_id from public.individual), needs_assessment_partitioned as (select single_select_coded (assessment.observations ->> '6ac76c57-66e4-40e7-b9bb-983f276f986a') as obs, assessment.program_enrolment_id, row_number() over (partition by assessment.individual_id order by assessment.encounter_date_time desc ) as rn from program_encounter as assessment where assessment.individual_id in (select ind_id from all_filtered_applied) and encounter_date_time::date between '2023-09-01'::date and '2023-09-19'::date and assessment.encounter_type_id = 66) select unnest(ARRAY [ 'Number of pregnant women in the reporting month (as per eligible couple program)', 'Number of pregnant women in the reporting month (as per pregnancy program)' ]) Indicator, unnest(ARRAY [ count(distinct ecenl.individual_id) filter ( where obs = 'Yes' and ecenl.program_exit_date_time isnull), count(distinct enl.individual_id) filter ( where obs = 'Yes') ]) Actual from public.individual ind left join program_enrolment enl on ind.id = enl.individual_id and enl.is_voided = false and enl.program_id = 1 left join program_enrolment ecenl on ecenl.individual_id = ind.id and ecenl.is_voided = false and ecenl.program_id = 11 left join needs_assessment_partitioned latest on latest.program_enrolment_id = ecenl.id and latest.rn = 1 where ind.id in (select ind_id from all_filtered_applied) and ind.is_voided = false;

nupoorkhandelwal commented 1 year ago

### Ticket has been re-opened, same changes need to be done in the Combined MPR (Child and Needs assessment) report as well.