select individual.observations ->> 'c9e64f06-23ac-47dc-b7e4-c93b819f52ce' identifier, audit.last_modified_date_time from individual
    join audit on individual.audit_id = audit.id
where individual.observations ->> 'c9e64f06-23ac-47dc-b7e4-c93b819f52ce' = 'IDENTIFIER' and individual.is_voided = false;

select program.name program_name, program_enrolment.id enrolment_id, audit.last_modified_date_time enrolment_last_modified from individual
    left outer join program_enrolment on individual.id = program_enrolment.individual_id
    left outer join audit on program_enrolment.audit_id = audit.id
    left outer join program on program_enrolment.program_id = program.id
where individual.observations ->> 'c9e64f06-23ac-47dc-b7e4-c93b819f52ce' = '11070508'  and individual.is_voided = false and program_enrolment.is_voided = false;

select program.name program_name, et.name encounter_type_name, audit.last_modified_date_time program_encounter_last_modified from individual
         left outer join program_enrolment on individual.id = program_enrolment.individual_id
         left outer join program_encounter on program_enrolment.id = program_encounter.program_enrolment_id
         left outer join audit on program_encounter.audit_id = audit.id
         left outer join program on program_enrolment.program_id = program.id
         left outer join encounter_type et on audit.id = et.audit_id
    where individual.observations ->> 'c9e64f06-23ac-47dc-b7e4-c93b819f52ce' = 'IDENTIFIER'  and individual.is_voided = false and program_enrolment.is_voided = false and program_encounter.is_voided = false;

select encounter_type.name encounter_type_name, audit.last_modified_date_time encounter_last_modified from individual
   left outer join encounter on individual.id = encounter.individual_id
   left outer join audit on encounter.audit_id = audit.id
   left outer join encounter_type on encounter.encounter_type_id = encounter_type.id
    where individual.observations ->> 'c9e64f06-23ac-47dc-b7e4-c93b819f52ce' = 'IDENTIFIER'  and individual.is_voided = false and encounter.is_voided = false;
