avniproject / Adolescent-Sewa-Rural

0 stars 0 forks source link

[Sewa Rural] Change in logic for Moderate and Severe Anemia #6

Closed utkarshavni closed 12 months ago

utkarshavni commented 1 year ago

Organization: UAT - Adolescent Sewa Rural UAT Prod - Adolescent Sewa Rural

Use case Hb range for different anemia category has been updated. Please check the sheet below: https://docs.google.com/spreadsheets/d/1umBm1lkuFNoHk-naE0uFV1ZAc6j02XC-rfV1rUauHHc/edit#gid=1277219951

Tasks:

Acceptance criteria Anemia status should be updated correctly based on the Hb ranges given.

vedfordev commented 1 year ago

Dev Test Scenario

Visit Schedule

individual : Test Visit Schedule

Encounter HB Severe Anemia Follow-up Moderate Anemia Follow-up
Annual Visit-Baseline 7.9 x
Annual Visit-Baseline 8 x
Annual Visit-Baseline 11 x x
Annual Visit-Baseline 10 x
Annual Visit-Baseline 15 x x
Annual visit - Endline 7.9 x
Annual visit - Endline 8 x
Annual visit - Endline 11 x x
Annual visit - Endline 10 x
Annual visit - Endline 15 x x
Severe Anemia followup 7.9 x
Severe Anemia followup 8 x
Severe Anemia followup 11 x x
Severe Anemia followup 10 x
Severe Anemia followup 15 x x
Moderate Anemia followup 7.9 x
Moderate Anemia followup 8 x
Moderate Anemia followup 11 x x
Moderate Anemia followup 10 x
Moderate Anemia followup 15 x x

Uat query : Link

vedfordev commented 1 year ago

Code for dashboard count check:

replace with catchment

select count(distinct id) filter ( where "Haemoglobin" < 8 ) as "severe as per Haemoglobin",
       count(distinct id) filter ( where "Anemic Status" =  '["1f92d18a-2c91-4421-8c41-2cc56f799c6d"]' ) as "severe as per Anemic Status",
       count(distinct id) filter ( where "Haemoglobin" >= 8  and "Haemoglobin" < 11) as "moderate as per Haemoglobin",
       count(distinct id) filter ( where "Anemic Status" =  '["830319d4-b616-4253-88ff-00ada2b3ff03"]' ) as "moderate as per Anemic Status"
from (
    with level as(
        select distinct addresslevel_id
        from catchment_address_mapping
        where catchment_id = (select id from catchment where name = 'Master')
    )
    select ind.id,
           (pe.observations->>'d304f306-deca-4418-a9a5-27b04e083623')::text  "Anemic Status",
           (pe.observations->>'0f283bcc-fa4c-4d98-93fd-cbf1729b770d')::numeric "Haemoglobin",
           row_number() over (partition by pe.individual_id order by encounter_date_time desc  nulls last) "enc_no"
    from individual ind
    join level l on ind.address_id = l.addresslevel_id
    join program_enrolment enl on enl.individual_id = ind.id and enl.program_exit_date_time isnull
    join program_encounter pe on pe.individual_id = ind.id
    where ind.is_voided = false
        and  pe.encounter_type_id in (select id from encounter_type where is_voided = false and (name = 'Annual Visit - Baseline' or name = 'Annual Visit - Endline' or name = 'Moderate Anemia Follow-up' or name = 'Severe Anemia Follow-up'))
        and pe.is_voided = false
        and pe.encounter_date_time notnull
)as foo
where enc_no = 1
;