From 44511804aa1cb7e7c037ae6be6be9dd60bb83738 Mon Sep 17 00:00:00 2001 From: KekeletsoNtho Date: Fri, 27 Oct 2023 11:39:04 +0200 Subject: [PATCH] Revision of weekly report completeness --- Serialized_Object.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Serialized_Object.sql b/Serialized_Object.sql index b8a410d..23dd0ee 100644 --- a/Serialized_Object.sql +++ b/Serialized_Object.sql @@ -1,8 +1,8 @@ --- MySQL dump 10.13 Distrib 5.7.30, for Linux (x86_64) +-- MySQL dump 10.13 Distrib 5.6.40, for Linux (x86_64) -- -- Host: localhost Database: openmrs -- ------------------------------------------------------ --- Server version 5.7.30 +-- Server version 5.6.40 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; @@ -71,7 +71,7 @@ INSERT INTO `serialized_object` VALUES (1801,'Clients given 6E weighing >= 35 kg INSERT INTO `serialized_object` VALUES (2056,'FactoryWorker_failed','Factory worker failed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n FactoryWorker_failed\n Factory worker failed\n \n 2023-04-03 07:36:11 UTC\n \n 2023-04-03 07:53:38 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2056\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3669 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (3793) \n and b.voided = 0 \n ) \n\n','2023-04-03 09:36:11',4,'2023-04-03 09:53:38',4,0,NULL,NULL,NULL,'43e35844-a8eb-4cc5-a3cd-445a052316c2'),(2057,'prison_worker_failed','Prison worker failed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n prison_worker_failed\n Prison worker failed\n \n 2023-04-03 07:55:07 UTC\n \n 2023-04-03 07:56:27 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2057\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3779 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (3793) \n and b.voided = 0 \n ) \n\n','2023-04-03 09:55:07',4,'2023-04-03 09:56:27',4,0,NULL,NULL,NULL,'a4dd9267-3676-4a8b-b56b-65b8683f1ba6'),(2058,'health_worker_failed','Health Worker Failed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n health_worker_failed\n Health Worker Failed\n \n 2023-04-03 07:57:33 UTC\n \n 2023-04-03 07:58:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2058\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3670 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (3793) \n and b.voided = 0 \n ) \n\n','2023-04-03 09:57:33',4,'2023-04-03 09:58:07',4,0,NULL,NULL,NULL,'da9db0e3-0d78-489c-bd35-eb7c68e345d0'),(2059,'public_transport_failed','Public Transport Failed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n public_transport_failed\n Public Transport Failed\n \n 2023-04-03 07:58:45 UTC\n \n 2023-04-03 07:59:38 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2059\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 4654 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (3793) \n and b.voided = 0 \n ) \n\n','2023-04-03 09:58:45',4,'2023-04-03 09:59:38',4,0,NULL,NULL,NULL,'33f5b01b-0001-4fbd-8d76-43b6616c4824'),(2060,'HHCM_failed','HHCM Failed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM_failed\n HHCM Failed\n \n 2023-04-03 09:18:29 UTC\n \n 2023-04-03 09:19:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2060\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3777 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (3793) \n and b.voided = 0 \n ) \n\n','2023-04-03 11:18:29',4,'2023-04-03 11:19:51',4,0,NULL,NULL,NULL,'60d6cef7-079a-4825-b6e1-cb4eb655b864'),(2061,'Mine Workers Cured','Mine Workers Cured','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Mine Workers Cured\n Mine Workers Cured\n \n 2023-04-03 09:18:52 UTC\n \n 2023-04-04 12:32:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2061\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in(Select distinct Id \n From( \n select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n pi2.identifier AS TB_Number, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n observed_age_group.name AS age_group, \n person.gender AS Gender, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- TB Clients \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = o.person_id AND pi2.identifier_type in (7) \n AND o.voided=0 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n AND o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n -- Mine Worker \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3776 and o.value_coded = 3667 \n and o.voided = 0 \n ) \n -- TB Treatment Outcome \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded = 1068 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-04-03 11:18:52',4,'2023-04-04 14:32:36',4,0,NULL,NULL,NULL,'9fffbcb9-e2f8-43d2-b6ae-b257c80ff52c'),(2062,'Mine Workers Completed','Mine Workers Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Mine Workers Completed\n Mine Workers Completed\n \n 2023-04-03 09:20:24 UTC\n \n 2023-04-04 12:31:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2062\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in(Select distinct Id \n From( \n select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n pi2.identifier AS TB_Number, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n observed_age_group.name AS age_group, \n person.gender AS Gender, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- TB Clients \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = o.person_id AND pi2.identifier_type in (7) \n AND o.voided=0 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n AND o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n -- Mine Worker \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3776 and o.value_coded = 3667 \n and o.voided = 0 \n ) \n -- TB Treatment Outcome \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded = 2242 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-04-03 11:20:24',4,'2023-04-04 14:31:40',4,0,NULL,NULL,NULL,'22a95602-7db7-453f-8af1-d3314651365b'),(2063,'HHXM_completed','HHXM Completed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM_completed\n HHXM Completed\n \n 2023-04-03 09:20:26 UTC\n \n 2023-04-03 09:21:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2063\n \nselect distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3778 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (2242) \n and b.voided = 0 \n ) \n\n','2023-04-03 11:20:26',4,'2023-04-03 11:21:05',4,0,NULL,NULL,NULL,'bc440ff8-a03c-42b4-b082-393873e19cc5'),(2064,'HHXM_failed','HHXM Failed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM_failed\n HHXM Failed\n \n 2023-04-03 09:21:50 UTC\n \n 2023-04-03 22:08:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2064\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3778 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (3793) \n and b.voided = 0 \n ) \n\n','2023-04-03 11:21:50',4,'2023-04-04 00:08:02',4,0,NULL,NULL,NULL,'168f05ac-dc2e-4c53-a38b-0d1ac6bc3f4c'),(2065,'Mine Workers Died','Mine Workers Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Mine Workers Died\n Mine Workers Died\n \n 2023-04-03 09:22:05 UTC\n \n 2023-04-04 12:33:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2065\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in(Select distinct Id \n From( \n select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n pi2.identifier AS TB_Number, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n observed_age_group.name AS age_group, \n person.gender AS Gender, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- TB Clients \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = o.person_id AND pi2.identifier_type in (7) \n AND o.voided=0 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n AND o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n -- Mine Worker \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3776 and o.value_coded = 3667 \n and o.voided = 0 \n ) \n -- TB Treatment Outcome \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded = 3650 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-04-03 11:22:05',4,'2023-04-04 14:33:00',4,0,NULL,NULL,NULL,'75e3ca1f-9e04-4d1c-91ae-f79f18f650ee'),(2066,'HHXM_cured','HHXM Curred\r\n','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM_cured\n HHXM Curred \n\n \n 2023-04-03 09:22:14 UTC\n \n 2023-04-03 09:22:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2066\n \nselect distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3778 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (1068) \n and b.voided = 0 \n ) \n\n','2023-04-03 11:22:14',4,'2023-04-03 11:22:50',4,0,NULL,NULL,NULL,'1895c8dd-bf2c-4bd3-a48f-08770e349ffe'),(2067,'HHXM_moved','HHXM Moved','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM_moved\n HHXM Moved\n \n 2023-04-03 09:24:40 UTC\n \n 2023-04-03 09:27:22 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2067\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3778 \n and ob.voided = 0 \n ) \n and o.person_id in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (3794) \n and b.voided = 0 \n ) \n\n','2023-04-03 11:24:40',4,'2023-04-03 11:27:22',4,0,NULL,NULL,NULL,'458408ac-2fc6-45e2-a884-8b8a75cf1d94'),(2068,'HHXM_lost','HHXM Lost','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM_lost\n HHXM Lost\n \n 2023-04-03 09:26:54 UTC\n \n 2023-04-03 09:27:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2068\n \nselect distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3778 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (2302) \n and b.voided = 0 \n ) \n\n','2023-04-03 11:26:54',4,'2023-04-03 11:27:10',4,0,NULL,NULL,NULL,'20694047-0786-4ce8-922b-df3b23f39c56'),(2069,'Mine Workers Lost to Follow up','Mine Workers Lost to Follow up','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Mine Workers Lost to Follow up\n Mine Workers Lost to Follow up\n \n 2023-04-03 09:26:54 UTC\n \n 2023-04-04 12:33:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2069\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in(Select distinct Id \n From( \n select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n pi2.identifier AS TB_Number, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n observed_age_group.name AS age_group, \n person.gender AS Gender, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- TB Clients \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = o.person_id AND pi2.identifier_type in (7) \n AND o.voided=0 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n AND o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n -- Mine Worker \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3776 and o.value_coded = 3667 \n and o.voided = 0 \n ) \n -- TB Treatment Outcome \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded = 2302 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-04-03 11:26:54',4,'2023-04-04 14:33:39',4,0,NULL,NULL,NULL,'9406df9e-8673-48f0-81eb-21b60a5ded97'),(2070,'hhxm_notEvaluated','HHXm Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n hhxm_notEvaluated\n HHXm Not Evaluated\n \n 2023-04-03 09:28:30 UTC\n \n 2023-04-03 09:29:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2070\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3778 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (2302,1068,2242,3650,3793,3794) \n and b.voided = 0 \n ) \n\n','2023-04-03 11:28:30',4,'2023-04-03 11:29:51',4,0,NULL,NULL,NULL,'0bd16759-6ff9-4cbf-a0b0-8e9fd1efd1be'),(2071,'Mine Workers Failed (Susceptible)','Mine Workers Failed (Susceptible)','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Mine Workers Failed (Susceptible)\n Mine Workers Failed (Susceptible)\n \n 2023-04-03 09:33:26 UTC\n \n 2023-04-04 12:33:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2071\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in(Select distinct Id \n From( \n select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n pi2.identifier AS TB_Number, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n observed_age_group.name AS age_group, \n person.gender AS Gender, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- TB Clients \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = o.person_id AND pi2.identifier_type in (7) \n AND o.voided=0 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n AND o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n -- Mine Worker \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3776 and o.value_coded = 3667 \n and o.voided = 0 \n ) \n -- TB Treatment Outcome \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded = 3793 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-04-03 11:33:26',4,'2023-04-04 14:33:18',4,0,NULL,NULL,NULL,'4bba1fe8-13ad-4c18-b549-f0aff1e6bc3f'),(2072,'hhxm_died','HHXM Died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n hhxm_died\n HHXM Died\n \n 2023-04-03 09:34:30 UTC\n \n 2023-04-03 10:13:34 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2072\n select distinct o.person_id \n from obs o \n inner join location l on o.location_id = l.location_id \n WHERE (o.location_id =:location or parent_location =:location) \n and o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 \n and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n and o.person_id in ( \n select ob.person_id \n from obs ob \n where ob.concept_id = 3776 \n and ob.value_coded = 3778 \n and ob.voided = 0 \n ) \n and o.person_id not in ( \n select b.person_id \n from obs b \n where b.concept_id = 3792 \n and b.value_coded in (3650) \n and b.voided = 0 \n ) \n\n','2023-04-03 11:34:30',4,'2023-04-03 12:13:34',4,0,NULL,NULL,NULL,'173bca27-99d3-497c-b83f-902bd3502875'),(2073,'Mine Workers Moved to Secondline Treatment','Mine Workers Moved to Secondline Treatment','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Mine Workers Moved to Secondline Treatment\n Mine Workers Moved to Secondline Treatment\n \n 2023-04-03 09:36:03 UTC\n \n 2023-04-04 12:29:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2073\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in(Select distinct Id \n From( \n select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n pi2.identifier AS TB_Number, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n observed_age_group.name AS age_group, \n person.gender AS Gender, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- TB Clients \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = o.person_id AND pi2.identifier_type in (7) \n AND o.voided=0 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n AND o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n -- Mine Worker \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3776 and o.value_coded = 3667 \n and o.voided = 0 \n ) \n -- TB Treatment Outcome \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded = 3794 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-04-03 11:36:03',4,'2023-04-04 14:29:57',4,0,NULL,NULL,NULL,'7f349b74-1609-4786-a666-6f26b3e0934c'),(2074,'Mine Workers Not Evaluated','Mine Workers Not Evaluated','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Mine Workers Not Evaluated\n Mine Workers Not Evaluated\n \n 2023-04-03 09:39:03 UTC\n \n 2023-04-03 09:39:38 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2074\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in(Select distinct Id \n From( \n select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n pi2.identifier AS TB_Number, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n observed_age_group.name AS age_group, \n person.gender AS Gender, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- TB Clients \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = o.person_id AND pi2.identifier_type in (7) \n AND o.voided=0 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n AND o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n -- Mine Worker \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3776 and o.value_coded = 3667 \n and o.voided = 0 \n ) \n -- TB Treatment Outcome \n and o.person_id not in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded in (1068,2302,3650,3793,2242,3794) \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-04-03 11:39:03',4,'2023-04-03 11:39:38',4,0,NULL,NULL,NULL,'3f20bdd4-03b5-48eb-be2e-3e7d96d9608f'),(2075,'New and Relapse Completed','New and Relapse Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n New and Relapse Completed\n New and Relapse Completed\n \n 2023-04-03 09:46:12 UTC\n \n 2023-04-03 09:50:04 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2075\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 11:46:12',4,'2023-04-03 11:50:04',4,0,NULL,NULL,NULL,'bf8fffec-423b-4d4f-9082-a61937680e08'),(2076,'TB New and Relapse Cured','TB New and Relapse Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Cured\n TB New and Relapse Cured\n \n 2023-04-03 09:54:54 UTC\n \n 2023-04-03 10:09:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2076\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 11:54:54',4,'2023-04-03 12:09:07',4,0,NULL,NULL,NULL,'cc3e6b66-c906-4723-bf8b-f1e3bd9a4f48'),(2077,'TB New and Relapse Died','TB New and Relapse Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Died\n TB New and Relapse Died\n \n 2023-04-03 10:09:39 UTC\n \n 2023-04-03 10:26:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2077\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:09:39',4,'2023-04-03 12:26:07',4,0,NULL,NULL,NULL,'cdd51d3f-4922-459d-a23e-a62718354d0f'),(2078,'TB New and Relapse Lost to Follow-up','TB New and Relapse Lost to Follow-up','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Lost to Follow-up\n TB New and Relapse Lost to Follow-up\n \n 2023-04-03 10:13:30 UTC\n \n 2023-04-03 10:22:25 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2078\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:13:30',4,'2023-04-03 12:22:25',4,0,NULL,NULL,NULL,'e63623be-d56c-4e8a-9fb8-fcbfd651b326'),(2079,'Ex Miner - Died','Ex Miner Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner - Died\n Ex Miner Died\n \n 2023-04-03 10:15:01 UTC\n \n 2023-04-03 10:18:31 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2079\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:15:01',4,'2023-04-03 12:18:31',4,0,NULL,NULL,NULL,'4c0567b3-bc02-4b62-be5b-4e348a8a17d5'),(2080,'Ex Miner - Lost','Ex Miner Lost','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner - Lost\n Ex Miner Lost\n \n 2023-04-03 10:15:38 UTC\n \n 2023-04-03 10:20:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2080\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:15:38',4,'2023-04-03 12:20:44',4,0,NULL,NULL,NULL,'1001e669-922a-43ba-be6c-4e909e4d7f30'),(2081,'Ex Miner - Not Evaluated','Ex Miner Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner - Not Evaluated\n Ex Miner Not Evaluated\n \n 2023-04-03 10:16:26 UTC\n \n 2023-04-03 10:25:22 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2081\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:16:26',4,'2023-04-03 12:25:22',4,0,NULL,NULL,NULL,'95297d99-247c-4cb1-8454-8cde32e41699'),(2082,'Ex Miner - Completed','Ex Miner - Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner - Completed\n Ex Miner - Completed\n \n 2023-04-03 10:21:16 UTC\n \n 2023-04-03 10:53:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2082\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:21:16',4,'2023-04-03 12:53:45',4,0,NULL,NULL,NULL,'6512f126-9e67-46ba-aaab-e783a36a4efa'),(2083,'Ex Miner - Moved Second Line','Ex Miner moved second line','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner - Moved Second Line\n Ex Miner moved second line\n \n 2023-04-03 10:22:16 UTC\n \n 2023-04-03 10:24:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2083\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:22:16',4,'2023-04-03 12:24:44',4,0,NULL,NULL,NULL,'7de4354e-95cb-4f66-8d40-0bd243779ee4'),(2084,'TB New and Relapse Failed (Susceptible)','TB New and Relapse Failed (Susceptible)','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Failed (Susceptible)\n TB New and Relapse Failed (Susceptible)\n \n 2023-04-03 10:26:32 UTC\n \n 2023-04-03 11:24:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2084\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:26:32',4,'2023-04-03 13:24:51',4,0,NULL,NULL,NULL,'e3218a64-d243-48aa-9b9a-bbcda0104ae7'),(2085,'Ex Miner - Failed','Ex Miner - Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner - Failed\n Ex Miner - Failed\n \n 2023-04-03 10:27:35 UTC\n \n 2023-04-03 11:24:34 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2085\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:27:35',4,'2023-04-03 13:24:34',4,0,NULL,NULL,NULL,'aa17ed03-51ed-4fde-8ad9-164f975ded80'),(2086,'TB New and Relapse Moved to second line treatment','TB New and Relapse Moved to second line treatment','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Moved to second line treatment\n TB New and Relapse Moved to second line treatment\n \n 2023-04-03 10:27:42 UTC\n \n 2023-04-03 10:29:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2086\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:27:42',4,'2023-04-03 12:29:11',4,0,NULL,NULL,NULL,'687406cb-8ffe-4b7a-a806-583e78f04e48'),(2087,'Ex Miner - Cured','Ex Miner - Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Ex Miner - Cured\n Ex Miner - Cured\n \n 2023-04-03 10:28:42 UTC\n \n 2023-04-04 09:25:16 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2087\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 12:28:42',4,'2023-04-04 11:25:16',4,0,NULL,NULL,NULL,'6210a6de-cdbc-411c-b9fc-e6a6bf2f42bc'),(2088,'Factory Worker - Complete','Factory Worker - Complete','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Worker - Complete\n Factory Worker - Complete\n \n 2023-04-03 11:31:19 UTC\n \n 2023-04-03 11:33:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2088\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 13:31:19',4,'2023-04-03 13:33:02',4,0,NULL,NULL,NULL,'d1ce4f4f-9869-4fdd-afa5-da1899ae3815'),(2089,'Factory Worker - Cured','Factory Worker - Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Worker - Cured\n Factory Worker - Cured\n \n 2023-04-03 11:35:29 UTC\n \n 2023-04-03 11:37:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2089\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 13:35:29',4,'2023-04-03 13:37:51',4,0,NULL,NULL,NULL,'b92fab4d-1381-445b-abb1-1ba06b0957d4'),(2090,'Factory Worker - Died','Factory Worker - Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Worker - Died\n Factory Worker - Died\n \n 2023-04-03 11:37:01 UTC\n \n 2023-04-03 11:39:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2090\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 13:37:01',4,'2023-04-03 13:39:08',4,0,NULL,NULL,NULL,'ef65034d-ed9d-452d-af2f-ababeecfa6ad'),(2091,'Factory Worker - Lost','Factory Worker - Lost','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Worker - Lost\n Factory Worker - Lost\n \n 2023-04-03 11:38:56 UTC\n \n 2023-04-03 11:58:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2091\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 13:38:56',4,'2023-04-03 13:58:59',4,0,NULL,NULL,NULL,'a9e56df4-43a7-4387-828d-10c9dfb89245'),(2092,'Factory Worker - Not Evaluated','Factory Worker - Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Worker - Not Evaluated\n Factory Worker - Not Evaluated\n \n 2023-04-03 11:43:52 UTC\n \n 2023-04-03 11:59:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2092\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 13:43:52',4,'2023-04-03 13:59:10',4,0,NULL,NULL,NULL,'77cd1821-951d-42ed-a866-5f08fd800a9c'),(2093,'TB New and Relapse Not Evaluated','TB New and Relapse Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB New and Relapse Not Evaluated\n TB New and Relapse Not Evaluated\n \n 2023-04-03 11:45:15 UTC\n \n 2023-04-03 11:52:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2093\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 13:45:15',4,'2023-04-03 13:52:49',4,0,NULL,NULL,NULL,'8c3908aa-5ac3-4dc9-9261-cdd7fc07e365'),(2094,'Retreatment excluding Relapse Completed','Retreatment excluding Relapse Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment excluding Relapse Completed\n Retreatment excluding Relapse Completed\n \n 2023-04-03 19:27:03 UTC\n \n 2023-04-04 12:39:55 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2094\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:27:03',4,'2023-04-04 14:39:55',4,0,NULL,NULL,NULL,'f3df3cc6-11ba-4ef1-9b6b-eba700de0818'),(2095,'Factory Worker - Moved to 2nd line','Factory Worker - Moved to 2nd line','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Worker - Moved to 2nd line\n Factory Worker - Moved to 2nd line\n \n 2023-04-03 19:33:19 UTC\n \n 2023-04-03 19:35:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2095\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:33:19',4,'2023-04-03 21:35:06',4,0,NULL,NULL,NULL,'9ac7ec7c-6fa1-4771-8cb3-bcfca51f5e4b'),(2096,'Retreatment excluding Relapse Cured','Retreatment excluding Relapse Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment excluding Relapse Cured\n Retreatment excluding Relapse Cured\n \n 2023-04-03 19:37:22 UTC\n \n 2023-04-03 19:42:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2096\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:37:22',4,'2023-04-03 21:42:14',4,0,NULL,NULL,NULL,'af4ccd45-738a-452f-ab0e-aa7588ecd131'),(2097,'Factory Worker - Failed','Factory Worker - Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Factory Worker - Failed\n Factory Worker - Failed\n \n 2023-04-03 19:44:52 UTC\n \n 2023-04-03 19:49:24 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2097\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:44:52',4,'2023-04-03 21:49:24',4,0,NULL,NULL,NULL,'f353300f-5673-4742-9115-c5b0b7e398e8'),(2098,'Retreatment excluding Relapse Died','Retreatment excluding Relapse Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment excluding Relapse Died\n Retreatment excluding Relapse Died\n \n 2023-04-03 19:48:30 UTC\n \n 2023-04-03 19:51:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2098\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:48:30',4,'2023-04-03 21:51:58',4,0,NULL,NULL,NULL,'ae6d7e28-203a-4141-b338-0a2faadc3662'),(2099,'Prison Worker - Died','Prison Worker - Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Died\n Prison Worker - Died\n \n 2023-04-03 19:50:39 UTC\n \n 2023-04-03 19:53:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2099\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:50:39',4,'2023-04-03 21:53:44',4,0,NULL,NULL,NULL,'93b06207-6e95-4711-aa58-31c3a88ef1c0'),(2100,'Prison Worker - Cured','Prison Worker - Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Cured\n Prison Worker - Cured\n \n 2023-04-03 19:53:11 UTC\n \n 2023-04-03 19:54:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2100\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:53:11',4,'2023-04-03 21:54:43',4,0,NULL,NULL,NULL,'2f32e1d7-b41d-4bb7-89a3-80c3243e4948'),(2101,'Retreatment excluding Relapse Lost to follow up','Retreatment excluding Relapse Lost to follow up','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment excluding Relapse Lost to follow up\n Retreatment excluding Relapse Lost to follow up\n \n 2023-04-03 19:53:33 UTC\n \n 2023-04-03 19:55:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2101\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:53:33',4,'2023-04-03 21:55:20',4,0,NULL,NULL,NULL,'e5c0a844-b04b-40b4-99a4-32232d7a740e'),(2102,'Prison Worker - Completed','Prison Worker - Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Completed\n Prison Worker - Completed\n \n 2023-04-03 19:55:01 UTC\n \n 2023-04-03 20:00:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2102\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:55:01',4,'2023-04-03 22:00:15',4,0,NULL,NULL,NULL,'a4e75f76-e839-46af-bdc6-8218f3df823c'),(2103,'Retreatment excluding Relapse Failed','Retreatment excluding Relapse Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment excluding Relapse Failed\n Retreatment excluding Relapse Failed\n \n 2023-04-03 19:57:02 UTC\n \n 2023-04-03 20:01:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2103\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:57:02',4,'2023-04-03 22:01:44',4,0,NULL,NULL,NULL,'abea75a9-417c-4570-a63e-5739c02c765e'),(2104,'Prison Worker - Not Evaluated','Prison Worker - Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Not Evaluated\n Prison Worker - Not Evaluated\n \n 2023-04-03 19:59:02 UTC\n \n 2023-04-03 20:00:31 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2104\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 21:59:02',4,'2023-04-03 22:00:31',4,0,NULL,NULL,NULL,'5f8c563b-7314-4359-8bb4-4f9d51fe2257'),(2105,'TB Treatment Outcome - Block 2','Block 2: TB/HIV Activities','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Treatment Outcome - Block 2\n Block 2: TB/HIV Activities\n \n 2023-04-03 20:01:22 UTC\n \n 2023-04-03 20:01:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2105\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-04-03 22:01:22',4,'2023-04-03 22:01:46',4,0,NULL,NULL,NULL,'e24dad06-5de1-4215-b021-85b95585a56b'),(2106,'TB Treatment Outcome - Block 2 Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Treatment Outcome - Block 2 Data Set\n \n 2023-04-03 20:01:46 UTC\n \n 2023-04-03 20:33:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2106\n \n \n DM_Sex\n \n \n \n \n \n \n \n \n ARTNw&Rl_F\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n \n \n \n ARTNw&Rl_M\n \n \n \n \n DM_Sex\n Males\n \n \n \n \n \n ARTRetr_F\n \n \n \n \n \n \n \n \n \n ARTRetr_M\n \n \n \n \n \n \n DapNw&Rl_F\n \n \n \n \n \n \n \n \n \n DapNw&Rl_M\n \n \n \n \n \n \n DapRetre_F\n \n \n \n \n \n \n \n \n \n DapRetre_M\n \n \n \n \n \n \n PosNw&Rs_F\n \n \n \n \n \n \n \n \n \n PosNw&Rs_M\n \n \n \n \n \n \n PosRetr_F\n \n \n \n \n \n \n \n \n \n PosRetr_M\n \n \n \n \n \n \n StsNw&Rs_F\n \n \n \n \n \n \n \n \n \n StsNw&Rs_M\n \n \n \n \n \n \n StsRetre_F\n \n \n \n \n \n \n StsRetre_M\n \n \n \n \n \n \n','2023-04-03 22:01:46',4,'2023-04-03 22:33:35',4,0,NULL,NULL,NULL,'5730236a-dfc3-4bf5-8f18-3769e49f4519'),(2107,'Prison Worker - Failed','Prison Worker - Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Failed\n Prison Worker - Failed\n \n 2023-04-03 20:01:47 UTC\n \n 2023-04-03 20:07:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2107\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:01:47',4,'2023-04-03 22:07:43',4,0,NULL,NULL,NULL,'832801ab-b41b-4695-b0df-ada7c5c34ff7'),(2108,'Retreatment excluding Relapse Not Evaluated','Retreatment excluding Relapse Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment excluding Relapse Not Evaluated\n Retreatment excluding Relapse Not Evaluated\n \n 2023-04-03 20:02:36 UTC\n \n 2023-04-03 20:05:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2108\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:02:36',4,'2023-04-03 22:05:10',4,0,NULL,NULL,NULL,'9c3205c9-eb03-46c1-b7e8-a0e9fa4b4738'),(2109,'Prison Worker - Moved to 2nd line','Prison Worker - Moved to 2nd line','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Moved to 2nd line\n Prison Worker - Moved to 2nd line\n \n 2023-04-03 20:02:41 UTC\n \n 2023-04-03 20:05:28 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2109\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:02:41',4,'2023-04-03 22:05:28',4,0,NULL,NULL,NULL,'cee1771f-3491-455f-9b0a-a35e99f25454'),(2110,'Retreatment excluding Relapse Moved to Secondline Treatment','Retreatment excluding Relapse Moved to Secondline Treatment','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Retreatment excluding Relapse Moved to Secondline Treatment\n Retreatment excluding Relapse Moved to Secondline Treatment\n \n 2023-04-03 20:06:37 UTC\n \n 2023-04-03 20:20:31 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2110\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:06:37',4,'2023-04-03 22:20:31',4,0,NULL,NULL,NULL,'ee732817-3760-4a2d-9d61-f7009cd0b256'),(2111,'Prison Worker - Lost','Prison Worker - Lost','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Lost\n Prison Worker - Lost\n \n 2023-04-03 20:07:00 UTC\n \n 2023-04-03 20:10:16 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2111\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:07:00',4,'2023-04-03 22:10:16',4,0,NULL,NULL,NULL,'bfa5d083-f2ca-4c04-a6d3-193176de6d61'),(2112,'RetreatRetreatment excluding Relapse Moved to Secondline Treatment','RetreatRetreatment excluding Relapse Moved to Secondline Treatment','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n RetreatRetreatment excluding Relapse Moved to Secondline Treatment\n RetreatRetreatment excluding Relapse Moved to Secondline Treatment\n \n 2023-04-03 20:13:03 UTC\n \n 2023-04-03 20:14:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2112\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in(Select distinct Id \n From( \n select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n pi2.identifier AS TB_Number, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n observed_age_group.name AS age_group, \n person.gender AS Gender, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- TB Clients \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n LEFT JOIN patient_identifier pi2 ON pi2.patient_id = o.person_id AND pi2.identifier_type in (7) \n AND o.voided=0 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n AND o.concept_id in (4153, 1158) \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 2237 and o.voided = 0 \n and o.value_datetime >= DATE_ADD(CAST(:startDate AS DATE), INTERVAL -12 MONTH) \n and o.value_datetime <= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -12 MONTH) \n group by o.person_id \n ) \n -- Retreatment excluding Relapse \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3785 and o.value_coded in (3786,1037) \n and o.voided = 0 \n ) \n -- TB Treatment Outcome \n and o.person_id in ( \n select o.person_id \n from obs o \n where o.concept_id = 3792 and o.value_coded = 3794 \n and o.voided = 0 \n ) \n \n Group by o.person_id) AS TB_TESTING \n) \n\n','2023-04-03 22:13:03',4,'2023-04-03 22:14:36',4,0,NULL,NULL,NULL,'2573846a-4c51-4427-bcba-7ed91d2c0835'),(2113,'Health Worker - Died','Health Worker - Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health Worker - Died\n Health Worker - Died\n \n 2023-04-03 20:14:38 UTC\n \n 2023-04-03 20:16:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2113\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:14:38',4,'2023-04-03 22:16:57',4,0,NULL,NULL,NULL,'15cca65b-c4f6-4e32-8b7d-18cb047f999a'),(2114,'Health Worker - Cured','Health Worker - Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health Worker - Cured\n Health Worker - Cured\n \n 2023-04-03 20:16:23 UTC\n \n 2023-04-03 20:18:17 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2114\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:16:23',4,'2023-04-03 22:18:17',4,0,NULL,NULL,NULL,'efe0083b-cc7c-4394-bf4d-e4129ee2d998'),(2115,'Prison Worker - Completed','Prison Worker - Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Completed\n Prison Worker - Completed\n \n 2023-04-03 20:18:34 UTC\n \n 2023-04-03 20:22:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2115\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:18:34',4,'2023-04-03 22:22:51',4,0,NULL,NULL,NULL,'685d03a5-0f34-426e-aa83-e12e209284b4'),(2116,'Prison Worker - Failed','Prison Worker - Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Prison Worker - Failed\n Prison Worker - Failed\n \n 2023-04-03 20:20:00 UTC\n \n 2023-04-03 20:22:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2116\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:20:00',4,'2023-04-03 22:22:29',4,0,NULL,NULL,NULL,'792e1555-e40d-4ebf-8b96-ebbaa769f859'),(2117,'All TB HIV positive Completed','All TB HIV positive Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV positive Completed\n All TB HIV positive Completed\n \n 2023-04-03 20:21:28 UTC\n \n 2023-04-03 20:31:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2117\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:21:28',4,'2023-04-03 22:31:15',4,0,NULL,NULL,NULL,'18f345bc-6ed0-42d6-893a-05ba98b38e16'),(2118,'All TB HIV positive Cured','All TB HIV positive Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV positive Cured\n All TB HIV positive Cured\n \n 2023-04-03 20:25:37 UTC\n \n 2023-04-03 20:32:16 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2118\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:25:37',4,'2023-04-03 22:32:16',4,0,NULL,NULL,NULL,'4b6e2cd9-29b6-4f7b-8af7-0ab18e2af838'),(2119,'Health Worker - Completed','Health Worker - Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health Worker - Completed\n Health Worker - Completed\n \n 2023-04-03 20:32:38 UTC\n \n 2023-04-03 20:39:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2119\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:32:38',4,'2023-04-03 22:39:58',4,0,NULL,NULL,NULL,'b38f490e-8d26-411a-9073-2a7e5d17e235'),(2120,'All TB HIV positive and Died','All TB HIV positive and Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV positive and Died\n All TB HIV positive and Died\n \n 2023-04-03 20:32:43 UTC\n \n 2023-04-03 20:35:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2120\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:32:43',4,'2023-04-03 22:35:39',4,0,NULL,NULL,NULL,'f0b13ce3-b836-4a27-a7a4-d1b83c1eb900'),(2121,'Health Worker - Not Evaluated','Health Worker - Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health Worker - Not Evaluated\n Health Worker - Not Evaluated\n \n 2023-04-03 20:32:56 UTC\n \n 2023-04-03 20:35:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2121\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:32:56',4,'2023-04-03 22:35:43',4,0,NULL,NULL,NULL,'9f750645-0dc4-488d-8a94-05e31d6b4838'),(2122,'All TB HIV positive and Lost to Follow Up','All TB HIV positive and Lost to Follow Up','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV positive and Lost to Follow Up\n All TB HIV positive and Lost to Follow Up\n \n 2023-04-03 20:33:45 UTC\n \n 2023-04-03 20:36:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2122\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:33:45',4,'2023-04-03 22:36:08',4,0,NULL,NULL,NULL,'21738598-0974-4f31-9925-1c9606d66410'),(2123,'All TB HIV positive and Failed','All TB HIV positive and Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV positive and Failed\n All TB HIV positive and Failed\n \n 2023-04-03 20:36:30 UTC\n \n 2023-04-03 20:40:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2123\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:36:30',4,'2023-04-03 22:40:18',4,0,NULL,NULL,NULL,'2a7766be-418e-4a5a-a204-c5fa91e6b672'),(2124,'All TB HIV positive and Not Evaluated','All TB HIV positive and Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV positive and Not Evaluated\n All TB HIV positive and Not Evaluated\n \n 2023-04-03 20:37:09 UTC\n \n 2023-04-03 20:39:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2124\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:37:09',4,'2023-04-03 22:39:20',4,0,NULL,NULL,NULL,'04c0074a-fd87-44da-8d96-68d533e488ea'),(2125,'Health Worker - Lost','Health Worker - Lost','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health Worker - Lost\n Health Worker - Lost\n \n 2023-04-03 20:40:25 UTC\n \n 2023-04-03 20:44:16 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2125\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:40:25',4,'2023-04-03 22:44:16',4,0,NULL,NULL,NULL,'925a50ba-435b-4213-a03b-6272a468cd01'),(2126,'All TB HIV positive and Moved to Secondline Treatment','All TB HIV positive and Moved to Secondline Treatment','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV positive and Moved to Secondline Treatment\n All TB HIV positive and Moved to Secondline Treatment\n \n 2023-04-03 20:40:57 UTC\n \n 2023-04-03 20:42:27 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2126\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:40:57',4,'2023-04-03 22:42:27',4,0,NULL,NULL,NULL,'6ed079c9-5ad9-4852-9523-95fddcbc9959'),(2127,'Health Worker - Failed','Health Worker - Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health Worker - Failed\n Health Worker - Failed\n \n 2023-04-03 20:42:41 UTC\n \n 2023-04-03 20:52:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2127\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:42:41',4,'2023-04-03 22:52:06',4,0,NULL,NULL,NULL,'4ec08d1c-6427-44e0-b604-b960e585b190'),(2128,'All TB HIV Negative and Completed','All TB HIV Negative and Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Negative and Completed\n All TB HIV Negative and Completed\n \n 2023-04-03 20:43:07 UTC\n \n 2023-04-03 20:53:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2128\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:43:07',4,'2023-04-03 22:53:20',4,0,NULL,NULL,NULL,'d5786c86-ca76-43b1-b0a6-1bd90817af65'),(2129,'All TB HIV Negative and Cured','All TB HIV Negative and Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Negative and Cured\n All TB HIV Negative and Cured\n \n 2023-04-03 20:44:07 UTC\n \n 2023-04-03 20:49:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2129\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:44:07',4,'2023-04-03 22:49:20',4,0,NULL,NULL,NULL,'a564539f-267c-452a-99d2-0f61f7c88c4f'),(2130,'Health Worker - Moved to 2nd line','Health Worker - Moved to 2nd line','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Health Worker - Moved to 2nd line\n Health Worker - Moved to 2nd line\n \n 2023-04-03 20:48:45 UTC\n \n 2023-04-03 20:55:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2130\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:48:45',4,'2023-04-03 22:55:46',4,0,NULL,NULL,NULL,'c0d08cc2-25dc-48f6-a9bc-db0d9b376d17'),(2131,'All TB HIV Negative and Died','All TB HIV Negative and Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Negative and Died\n All TB HIV Negative and Died\n \n 2023-04-03 20:51:50 UTC\n \n 2023-04-03 20:55:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2131\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:51:50',4,'2023-04-03 22:55:29',4,0,NULL,NULL,NULL,'b375d3b0-9817-419c-ad36-5513383a0191'),(2132,'Public Transport - Died','Public Transport - Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public Transport - Died\n Public Transport - Died\n \n 2023-04-03 20:55:26 UTC\n \n 2023-04-03 20:57:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2132\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:55:26',4,'2023-04-03 22:57:21',4,0,NULL,NULL,NULL,'09f945ef-6ced-4c7c-924b-d83368e5b544'),(2133,'All TB HIV Negative and Failed','All TB HIV Negative and Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Negative and Failed\n All TB HIV Negative and Failed\n \n 2023-04-03 20:56:21 UTC\n \n 2023-04-03 21:00:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2133\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:56:21',4,'2023-04-03 23:00:30',4,0,NULL,NULL,NULL,'bce54b53-dea6-4664-bc35-b436a74551f0'),(2134,'All TB HIV Negative and Lost to Follow Up','All TB HIV Negative and Lost to Follow Up','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Negative and Lost to Follow Up\n All TB HIV Negative and Lost to Follow Up\n \n 2023-04-03 20:56:44 UTC\n \n 2023-04-03 21:00:04 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2134\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:56:44',4,'2023-04-03 23:00:04',4,0,NULL,NULL,NULL,'7b40659a-ca9a-4034-832f-5fddb0421d26'),(2135,'Public Transport - Not Evaluated','Public Transport - Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public Transport - Not Evaluated\n Public Transport - Not Evaluated\n \n 2023-04-03 20:56:54 UTC\n \n 2023-04-03 20:59:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2135\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:56:54',4,'2023-04-03 22:59:03',4,0,NULL,NULL,NULL,'0b001306-febd-4630-acb7-03fedc1eca0d'),(2136,'Public Transport - Completed','Public Transport - Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public Transport - Completed\n Public Transport - Completed\n \n 2023-04-03 20:58:25 UTC\n \n 2023-04-03 21:00:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2136\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 22:58:25',4,'2023-04-03 23:00:42',4,0,NULL,NULL,NULL,'cb8baffc-6e41-4464-91b4-478da43820ad'),(2137,'Public Transport - Lost','Public Transport - Lost','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public Transport - Lost\n Public Transport - Lost\n \n 2023-04-03 21:00:25 UTC\n \n 2023-04-03 21:04:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2137\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:00:25',4,'2023-04-03 23:04:00',4,0,NULL,NULL,NULL,'68abf753-d909-4d9d-866b-d707b637b5f6'),(2138,'All TB HIV Negative and Not Evaluated','All TB HIV Negative and Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Negative and Not Evaluated\n All TB HIV Negative and Not Evaluated\n \n 2023-04-03 21:00:53 UTC\n \n 2023-04-03 21:02:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2138\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:00:53',4,'2023-04-03 23:02:35',4,0,NULL,NULL,NULL,'56fc35af-e96c-4268-b7b4-0d63610a2d06'),(2139,'All TB HIV Negative and Moved to Secondline Treatment','All TB HIV Negative and Moved to Secondline Treatment','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB HIV Negative and Moved to Secondline Treatment\n All TB HIV Negative and Moved to Secondline Treatment\n \n 2023-04-03 21:01:36 UTC\n \n 2023-04-03 21:02:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2139\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:01:36',4,'2023-04-03 23:02:58',4,0,NULL,NULL,NULL,'bdf99672-96f9-4eda-ad34-a82f5b59ffbc'),(2140,'Public Transport - Cured','Public Transport - Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public Transport - Cured\n Public Transport - Cured\n \n 2023-04-03 21:02:12 UTC\n \n 2023-04-03 21:06:24 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2140\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:02:12',4,'2023-04-03 23:06:24',4,0,NULL,NULL,NULL,'185b4be8-a666-4211-b22d-56dc426cbbcd'),(2141,'All TB Children (0-14 yrs) and Completed','All TB Children (0-14 yrs) and Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Children (0-14 yrs) and Completed\n All TB Children (0-14 yrs) and Completed\n \n 2023-04-03 21:03:41 UTC\n \n 2023-04-03 21:05:56 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2141\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:03:41',4,'2023-04-03 23:05:56',4,0,NULL,NULL,NULL,'eb242fe9-dde6-4baa-b92f-7a7084920dd7'),(2142,'All TB Children (0-14 yrs) and Cured','All TB Children (0-14 yrs) and Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Children (0-14 yrs) and Cured\n All TB Children (0-14 yrs) and Cured\n \n 2023-04-03 21:04:01 UTC\n \n 2023-04-03 21:06:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2142\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:04:01',4,'2023-04-03 23:06:20',4,0,NULL,NULL,NULL,'88c4f217-bf94-4e84-9d4b-15f6747276ae'),(2143,'Public Transport - Moved to 2nd line','Public Transport - Moved to 2nd line','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public Transport - Moved to 2nd line\n Public Transport - Moved to 2nd line\n \n 2023-04-03 21:05:57 UTC\n \n 2023-04-03 21:10:23 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2143\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:05:57',4,'2023-04-03 23:10:23',4,0,NULL,NULL,NULL,'3d87ffb3-cfb1-4ac5-bf47-dcb3193e133b'),(2144,'All TB Children (0-14 yrs) and Died','All TB Children (0-14 yrs) and Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Children (0-14 yrs) and Died\n All TB Children (0-14 yrs) and Died\n \n 2023-04-03 21:06:48 UTC\n \n 2023-04-03 21:08:55 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2144\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:06:48',4,'2023-04-03 23:08:55',4,0,NULL,NULL,NULL,'30a341a8-2bf8-4e91-a9ee-41b6826e2cef'),(2145,'Public Transport - Failed','Public Transport - Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Public Transport - Failed\n Public Transport - Failed\n \n 2023-04-03 21:07:43 UTC\n \n 2023-04-03 21:09:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2145\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:07:43',4,'2023-04-03 23:09:40',4,0,NULL,NULL,NULL,'e9843f95-15c2-4d15-bd2c-bdfc19bc4767'),(2146,'All TB Children (0-14 yrs) and Lost to follow up','All TB Children (0-14 yrs) and Lost to follow up','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Children (0-14 yrs) and Lost to follow up\n All TB Children (0-14 yrs) and Lost to follow up\n \n 2023-04-03 21:08:17 UTC\n \n 2023-04-03 21:16:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2146\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:08:17',4,'2023-04-03 23:16:59',4,0,NULL,NULL,NULL,'33f4111b-438c-4da8-bc56-0c588f408444'),(2147,'All TB Children (0-14 yrs) and failed','All TB Children (0-14 yrs) and failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Children (0-14 yrs) and failed\n All TB Children (0-14 yrs) and failed\n \n 2023-04-03 21:09:49 UTC\n \n 2023-04-03 21:17:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2147\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:09:49',4,'2023-04-03 23:17:30',4,0,NULL,NULL,NULL,'af568cf8-77aa-4d45-ab4f-ca39418ba77d'),(2148,'HHCM - Completed','HHCM - Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM - Completed\n HHCM - Completed\n \n 2023-04-03 21:11:12 UTC\n \n 2023-04-03 21:13:17 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2148\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:11:12',4,'2023-04-03 23:13:17',4,0,NULL,NULL,NULL,'23d932aa-9c33-4aff-89ec-9028c25a03ef'),(2149,'All TB Children (0-14 yrs) and not evaluated','All TB Children (0-14 yrs) and not evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Children (0-14 yrs) and not evaluated\n All TB Children (0-14 yrs) and not evaluated\n \n 2023-04-03 21:12:28 UTC\n \n 2023-04-03 21:15:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2149\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:12:28',4,'2023-04-03 23:15:26',4,0,NULL,NULL,NULL,'12a47e2e-735f-4b72-9e0c-f9fc792f3fc8'),(2150,'HHCM - Failed','HHCM - Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM - Failed\n HHCM - Failed\n \n 2023-04-03 21:13:03 UTC\n \n 2023-04-03 21:35:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2150\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:13:03',4,'2023-04-03 23:35:08',4,0,NULL,NULL,NULL,'ce1c1a8e-9760-4a56-a885-4bc25de4f892'),(2151,'HHCM - Lost','HHCM - Lost','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM - Lost\n HHCM - Lost\n \n 2023-04-03 21:14:35 UTC\n \n 2023-04-03 21:36:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2151\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:14:35',4,'2023-04-03 23:36:26',4,0,NULL,NULL,NULL,'b9ee3b47-b5d7-42ed-9a47-4f61f77b6eeb'),(2152,'All TB Children (0-14 yrs) and moved to secondline treatment','All TB Children (0-14 yrs) and moved to secondline treatment','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Children (0-14 yrs) and moved to secondline treatment\n All TB Children (0-14 yrs) and moved to secondline treatment\n \n 2023-04-03 21:18:05 UTC\n \n 2023-04-03 21:30:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2152\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:18:05',4,'2023-04-03 23:30:14',4,0,NULL,NULL,NULL,'692b0f3e-9c3e-4a71-bba3-b6ae50963679'),(2153,'All TB Adolescent (10-19 yrs) and Completed','All TB Adolescent (10-19 yrs) and Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and Completed\n All TB Adolescent (10-19 yrs) and Completed\n \n 2023-04-03 21:27:45 UTC\n \n 2023-04-03 21:29:16 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2153\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:27:45',4,'2023-04-03 23:29:16',4,0,NULL,NULL,NULL,'ad3dbe97-3718-4885-a76d-36982b68f507'),(2154,'All TB Adolescent (10-19 yrs) and Cured','All TB Adolescent (10-19 yrs) and Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and Cured\n All TB Adolescent (10-19 yrs) and Cured\n \n 2023-04-03 21:28:37 UTC\n \n 2023-04-03 21:30:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2154\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:28:37',4,'2023-04-03 23:30:39',4,0,NULL,NULL,NULL,'ee2cd03a-51b0-4f81-81cc-40ab687629a8'),(2155,'All TB Adolescent (10-19 yrs) and Died','All TB Adolescent (10-19 yrs) and Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and Died\n All TB Adolescent (10-19 yrs) and Died\n \n 2023-04-03 21:30:59 UTC\n \n 2023-04-03 21:33:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2155\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:30:59',4,'2023-04-03 23:33:07',4,0,NULL,NULL,NULL,'f27e06d5-38ff-443b-8ce0-3cebb07f2eec'),(2156,'All TB Adolescent (10-19 yrs) and Lost to follow up','All TB Adolescent (10-19 yrs) and Lost to follow up','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and Lost to follow up\n All TB Adolescent (10-19 yrs) and Lost to follow up\n \n 2023-04-03 21:31:24 UTC\n \n 2023-04-03 21:33:27 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2156\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:31:24',4,'2023-04-03 23:33:27',4,0,NULL,NULL,NULL,'b7f7dbd4-f089-4ac4-9bc5-4c750a016a6c'),(2157,'All TB Adolescent (10-19 yrs) and failed','All TB Adolescent (10-19 yrs) and failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and failed\n All TB Adolescent (10-19 yrs) and failed\n \n 2023-04-03 21:31:48 UTC\n \n 2023-04-03 21:38:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2157\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:31:48',4,'2023-04-03 23:38:15',4,0,NULL,NULL,NULL,'6ab5cc07-88e8-4b34-9cb6-8d451336945a'),(2158,'All TB Adolescent (10-19 yrs) and Not Evaluated','All TB Adolescent (10-19 yrs) and Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and Not Evaluated\n All TB Adolescent (10-19 yrs) and Not Evaluated\n \n 2023-04-03 21:34:28 UTC\n \n 2023-04-03 21:36:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2158\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:34:28',4,'2023-04-03 23:36:44',4,0,NULL,NULL,NULL,'4465b2b0-282f-4b7a-8acc-ba9018cf82ca'),(2159,'All TB Adolescent (10-19 yrs) and Moved to Secondline treatment','All TB Adolescent (10-19 yrs) and Moved to Secondline treatment','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n All TB Adolescent (10-19 yrs) and Moved to Secondline treatment\n All TB Adolescent (10-19 yrs) and Moved to Secondline treatment\n \n 2023-04-03 21:34:49 UTC\n \n 2023-04-03 21:37:16 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2159\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:34:49',4,'2023-04-03 23:37:16',4,0,NULL,NULL,NULL,'fc47f473-d8f7-4b44-b969-4aee12de4036'),(2160,'HHCM - Not Evaluated','HHCM - Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM - Not Evaluated\n HHCM - Not Evaluated\n \n 2023-04-03 21:37:03 UTC\n \n 2023-04-03 21:42:22 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2160\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:37:03',4,'2023-04-03 23:42:22',4,0,NULL,NULL,NULL,'f801b15a-b96f-491f-a8b5-1fbee8ba9c83'),(2161,'Female and Completed','Female and Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Female and Completed\n Female and Completed\n \n 2023-04-03 21:37:55 UTC\n \n 2023-04-03 21:44:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2161\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:37:55',4,'2023-04-03 23:44:21',4,0,NULL,NULL,NULL,'615ab43e-7d60-462d-bab7-3ea00babd032'),(2162,'Female and Cured','Female and Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Female and Cured\n Female and Cured\n \n 2023-04-03 21:38:38 UTC\n \n 2023-04-03 21:46:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2162\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:38:38',4,'2023-04-03 23:46:42',4,0,NULL,NULL,NULL,'807438e3-b735-4310-9e68-24f15521e66d'),(2163,'HHCM - Cured','HHCM - Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM - Cured\n HHCM - Cured\n \n 2023-04-03 21:38:56 UTC\n \n 2023-04-03 21:42:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2163\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:38:56',4,'2023-04-03 23:42:00',4,0,NULL,NULL,NULL,'352d4e3a-8ea5-4848-a515-ea4a3a091d8f'),(2164,'TB Female and Died','TB Female and Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Female and Died\n TB Female and Died\n \n 2023-04-03 21:39:57 UTC\n \n 2023-04-03 21:47:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2164\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:39:57',4,'2023-04-03 23:47:30',4,0,NULL,NULL,NULL,'ab84625a-199b-4a80-99b9-9b89c8c02ba4'),(2165,'HHCM - Died','HHCM - Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM - Died\n HHCM - Died\n \n 2023-04-03 21:43:38 UTC\n \n 2023-04-03 21:46:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2165\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:43:38',4,'2023-04-03 23:46:59',4,0,NULL,NULL,NULL,'144c7351-4092-442d-ab8d-91cf1d13698c'),(2166,'HHCM - Moved to 2nd line','HHCM - Moved to 2nd line','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHCM - Moved to 2nd line\n HHCM - Moved to 2nd line\n \n 2023-04-03 21:44:32 UTC\n \n 2023-04-03 21:48:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2166\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:44:32',4,'2023-04-03 23:48:15',4,0,NULL,NULL,NULL,'a7391f1f-e1b2-415c-bde5-52d06b5616ad'),(2167,'TB Female and Lost to Follow up','TB Female and Lost to Follow up','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Female and Lost to Follow up\n TB Female and Lost to Follow up\n \n 2023-04-03 21:46:14 UTC\n \n 2023-04-03 21:48:16 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2167\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:46:14',4,'2023-04-03 23:48:16',4,0,NULL,NULL,NULL,'6ad8a1fc-9753-4d52-b40a-68c6c9089141'),(2168,'TB Female and Failed','TB Female and Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Female and Failed\n TB Female and Failed\n \n 2023-04-03 21:47:53 UTC\n \n 2023-04-03 21:49:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2168\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:47:53',4,'2023-04-03 23:49:44',4,0,NULL,NULL,NULL,'676800f0-5583-436b-b7ab-815f7d884f96'),(2169,'TB Female and Not Evaluated','TB Female and Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Female and Not Evaluated\n TB Female and Not Evaluated\n \n 2023-04-03 21:48:58 UTC\n \n 2023-04-03 21:53:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2169\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:48:58',4,'2023-04-03 23:53:30',4,0,NULL,NULL,NULL,'67a2aa65-3b21-45f8-bdba-fe284d683360'),(2170,'TB Female and moved to secondline','TB Female and moved to secondline','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Female and moved to secondline\n TB Female and moved to secondline\n \n 2023-04-03 21:49:27 UTC\n \n 2023-04-03 21:51:19 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2170\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:49:27',4,'2023-04-03 23:51:19',4,0,NULL,NULL,NULL,'eac53c81-f295-41ae-989d-26f66888caae'),(2171,'HHXM - Completed','HHXM - Completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM - Completed\n HHXM - Completed\n \n 2023-04-03 21:51:36 UTC\n \n 2023-04-03 21:56:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2171\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:51:36',4,'2023-04-03 23:56:49',4,0,NULL,NULL,NULL,'558ce9d9-35d7-4d49-8b41-f4c8cc979bdf'),(2172,'HHXM - Cured','HHXM - Cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM - Cured\n HHXM - Cured\n \n 2023-04-03 21:51:55 UTC\n \n 2023-04-03 21:57:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2172\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:51:55',4,'2023-04-03 23:57:44',4,0,NULL,NULL,NULL,'56f5154b-cb21-456b-8e13-508a0dc032ff'),(2173,'TB Mine Workers and completed','TB Mine Workers and completed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Mine Workers and completed\n TB Mine Workers and completed\n \n 2023-04-03 21:53:08 UTC\n \n 2023-04-03 21:56:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2173\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:53:08',4,'2023-04-03 23:56:07',4,0,NULL,NULL,NULL,'a54130b0-7643-4865-9a0e-6c70215d3046'),(2174,'TB Mine Workers and cured','TB Mine Workers and cured','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Mine Workers and cured\n TB Mine Workers and cured\n \n 2023-04-03 21:53:49 UTC\n \n 2023-04-03 21:57:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2174\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:53:49',4,'2023-04-03 23:57:45',4,0,NULL,NULL,NULL,'f5957799-79ad-4f08-9a68-c359c4b69ce3'),(2175,'TB Mine Workers and died','TB Mine Workers and died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Mine Workers and died\n TB Mine Workers and died\n \n 2023-04-03 21:55:02 UTC\n \n 2023-04-03 21:57:23 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2175\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:55:02',4,'2023-04-03 23:57:23',4,0,NULL,NULL,NULL,'fc3c4c67-738d-403a-9584-bd4a17942c24'),(2176,'HHXM - Died','HHXM - Died','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM - Died\n HHXM - Died\n \n 2023-04-03 21:56:35 UTC\n \n 2023-04-03 21:59:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2176\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:56:35',4,'2023-04-03 23:59:44',4,0,NULL,NULL,NULL,'2aaeab53-7906-480f-a51b-ebc9077a28ac'),(2177,'TB Mine Workers and lost to follow up','TB Mine Workers and lost to follow up','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Mine Workers and lost to follow up\n TB Mine Workers and lost to follow up\n \n 2023-04-03 21:58:16 UTC\n \n 2023-04-03 22:05:17 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2177\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:58:16',4,'2023-04-04 00:05:17',4,0,NULL,NULL,NULL,'2d37e108-26d4-4c69-aa41-dbcb4298d209'),(2178,'HHXM - Not Evaluated','HHXM - Not Evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM - Not Evaluated\n HHXM - Not Evaluated\n \n 2023-04-03 21:58:28 UTC\n \n 2023-04-03 22:01:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2178\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:58:28',4,'2023-04-04 00:01:46',4,0,NULL,NULL,NULL,'ffa409cc-0ce1-4ca0-9971-e339c3d29f8c'),(2179,'TB Mine Workers and failed','TB Mine Workers and failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Mine Workers and failed\n TB Mine Workers and failed\n \n 2023-04-03 21:58:31 UTC\n \n 2023-04-03 22:00:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2179\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:58:31',4,'2023-04-04 00:00:58',4,0,NULL,NULL,NULL,'f866bee9-323a-4a71-8e35-94cceaa3550d'),(2180,'TB Mine Workers and not evaluated','TB Mine Workers and not evaluated','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Mine Workers and not evaluated\n TB Mine Workers and not evaluated\n \n 2023-04-03 21:58:52 UTC\n \n 2023-04-03 22:04:47 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2180\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-03 23:58:52',4,'2023-04-04 00:04:47',4,0,NULL,NULL,NULL,'b2a2038e-f629-45ee-8033-f797caa6ac39'),(2181,'HHXM - Lost','HHXM - Lost','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM - Lost\n HHXM - Lost\n \n 2023-04-03 22:00:45 UTC\n \n 2023-04-03 22:04:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2181\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-04 00:00:45',4,'2023-04-04 00:04:15',4,0,NULL,NULL,NULL,'11bcf608-b1dd-492d-ba8a-cd3c9e19748f'),(2182,'HHXM - Failed','HHXM - Failed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM - Failed\n HHXM - Failed\n \n 2023-04-03 22:01:29 UTC\n \n 2023-04-03 22:11:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2182\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-04 00:01:29',4,'2023-04-04 00:11:06',4,0,NULL,NULL,NULL,'a10dc54c-654e-4f57-9df8-be1b14c50a14'),(2183,'TB Mine Workers and moved to secondline ','TB Mine Workers and moved to secondline ','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Mine Workers and moved to secondline \n TB Mine Workers and moved to secondline \n \n 2023-04-03 22:02:20 UTC\n \n 2023-04-03 22:11:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2183\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${endDate}\n \n \n \n','2023-04-04 00:02:20',4,'2023-04-04 00:11:10',4,0,NULL,NULL,NULL,'e07ad771-1ec2-4d4a-a085-5433cc94b7de'),(2184,'HHXM - Moved to 2nd Line','HHXM - Moved to 2nd Line','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HHXM - Moved to 2nd Line\n HHXM - Moved to 2nd Line\n \n 2023-04-03 22:03:46 UTC\n \n 2023-04-03 22:08:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2184\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-04-04 00:03:46',4,'2023-04-04 00:08:51',4,0,NULL,NULL,NULL,'b12d1160-3ba1-4b39-92b9-e765d0d9fe55'),(2185,'TB Treatment Outcome - Block 1','TB Treatment Outcome - Block 1','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Treatment Outcome - Block 1\n TB Treatment Outcome - Block 1\n \n 2023-04-03 22:07:23 UTC\n \n 2023-04-03 22:07:54 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2185\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-04-04 00:07:23',4,'2023-04-04 00:07:54',4,0,NULL,NULL,NULL,'a7cfcef1-57f5-4fbc-8a24-77fac2b219bf'),(2186,'TB Treatment Outcome - Block 1 Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB Treatment Outcome - Block 1 Data Set\n \n 2023-04-03 22:07:54 UTC\n \n 2023-04-04 12:21:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2186\n \n \n \n Fmale2nd\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n FmaleComp\n \n \n \n \n \n \n \n \n \n FmaleCured\n \n \n \n \n \n \n \n \n \n FmaleDied\n \n \n \n \n \n \n \n \n \n FmaleFaile\n \n \n \n \n \n \n \n \n \n FmaleLost\n \n \n \n \n \n \n \n \n \n FmaleNtEv\n \n \n \n \n \n \n \n \n \n Miner2nd\n \n \n \n \n \n \n \n \n \n MinerComp\n \n \n \n \n \n \n \n \n \n MinerCured\n \n \n \n \n \n \n \n \n \n MinerDied\n \n \n \n \n \n \n \n \n \n MinerFail\n \n \n \n \n \n \n \n \n \n MinerLost\n \n \n \n \n \n \n \n \n \n MinerNtEv\n \n \n \n \n \n \n \n \n \n NwRlps2nd\n \n \n \n \n \n \n \n \n \n NwRlpsComp\n \n \n \n \n \n \n \n \n \n NwRlpsCure\n \n \n \n \n \n \n \n \n \n NwRlpsDied\n \n \n \n \n \n \n \n \n \n NwRlpsLost\n \n \n \n \n \n \n \n \n \n NwRlpsNtEv\n \n \n \n \n \n \n \n \n \n NwRlpsfail\n \n \n \n \n \n \n \n \n \n RtrtEx2nd\n \n \n \n \n \n \n \n \n \n RtrtExComp\n \n \n \n \n \n \n \n \n \n RtrtExCure\n \n \n \n \n \n \n \n \n \n RtrtExDied\n \n \n \n \n \n \n \n \n \n RtrtExFail\n \n \n \n \n \n \n \n \n \n RtrtExLost\n \n \n \n \n \n \n \n \n \n RtrtExNtEv\n \n \n \n \n \n \n \n \n \n TBAdol2nd\n \n \n \n \n \n \n \n \n \n TBAdolComp\n \n \n \n \n \n \n \n \n \n TBAdolCure\n \n \n \n \n \n \n \n \n \n TBAdolDied\n \n \n \n \n \n \n \n \n \n TBAdolFail\n \n \n \n \n \n \n \n \n \n TBAdolLost\n \n \n \n \n \n \n \n \n \n TBAdolNtEv\n \n \n \n \n \n \n \n \n \n TBChld2nd\n \n \n \n \n \n \n \n \n \n TBChldCure\n \n \n \n \n \n \n \n \n \n TBChldDied\n \n \n \n \n \n \n \n \n \n TBChldFail\n \n \n \n \n \n \n \n \n \n TBChldLost\n \n \n \n \n \n \n \n \n \n TBChldNtEv\n \n \n \n \n \n \n \n \n \n TBNeg2nd\n \n \n \n \n \n \n \n \n \n TBNegCompl\n \n \n \n \n \n \n \n \n \n TBNegCured\n \n \n \n \n \n \n \n \n \n TBNegDied\n \n \n \n \n \n \n \n \n \n TBNegFaile\n \n \n \n \n \n \n \n \n \n TBNegLost\n \n \n \n \n \n \n \n \n \n TBNegNtEv\n \n \n \n \n \n \n \n \n \n TBPos2nd\n \n \n \n \n \n \n \n \n \n TBPosCompl\n \n \n \n \n \n \n \n \n \n TBPosCured\n \n \n \n \n \n \n \n \n \n TBPosDied\n \n \n \n \n \n \n \n \n \n TBPosFaile\n \n \n \n \n \n \n \n \n \n TBPosLost\n \n \n \n \n \n \n \n \n \n TBPosNtEv\n \n \n \n \n \n \n \n \n \n TbChldComp\n \n \n \n \n \n \n \n \n \n exM_comple\n \n \n \n \n \n \n \n \n \n exM_cured\n \n \n \n \n \n \n \n \n \n exM_died\n \n \n \n \n \n \n \n \n \n exM_failed\n \n \n \n \n \n \n \n \n \n exM_lost\n \n \n \n \n \n \n \n \n \n exM_moved\n \n \n \n \n \n \n \n \n \n exM_noteEv\n \n \n \n \n \n \n \n \n \n fact_Died\n \n \n \n \n \n \n \n \n \n fact_compl\n \n \n \n \n \n \n \n \n \n fact_cured\n \n \n \n \n \n \n fact_fail\n \n \n \n \n \n \n \n \n \n fact_lost\n \n \n \n \n \n \n \n \n \n fact_moved\n \n \n \n \n \n \n \n \n \n fact_notEv\n \n \n \n \n \n \n \n \n \n hcw_comple\n \n \n \n \n \n \n \n \n \n hcw_cured\n \n \n \n \n \n \n \n \n \n hcw_died\n \n \n \n \n \n \n \n \n \n hcw_failed\n \n \n \n \n \n \n \n \n \n hcw_lost\n \n \n \n \n \n \n \n \n \n hcw_moved\n \n \n \n \n \n \n \n \n \n hcw_notEva\n \n \n \n \n \n \n \n \n \n hhcm_compl\n \n \n \n \n \n \n \n \n \n hhcm_cured\n \n \n \n \n \n \n \n \n \n hhcm_died\n \n \n \n \n \n \n \n \n \n hhcm_evalu\n \n \n \n \n \n \n \n \n \n hhcm_faile\n \n \n \n \n \n \n \n \n \n hhcm_lost\n \n \n \n \n \n \n \n \n \n hhcm_moved\n \n \n \n \n \n \n \n \n \n hhx_comple\n \n \n \n \n \n \n \n \n \n hhxm_cured\n \n \n \n \n \n \n \n \n \n hhxm_died\n \n \n \n \n \n \n \n \n \n hhxm_faile\n \n \n \n \n \n \n \n \n \n hhxm_lost\n \n \n \n \n \n \n \n \n \n hhxm_moved\n \n \n \n \n \n \n \n \n \n hhxm_notEv\n \n \n \n \n \n \n \n \n \n ptran_comp\n \n \n \n \n \n \n \n \n \n ptran_cure\n \n \n \n \n \n \n \n \n \n ptran_died\n \n \n \n \n \n \n \n \n \n ptran_eval\n \n \n \n \n \n \n \n \n \n ptran_fail\n \n \n \n \n \n \n \n \n \n ptran_lost\n \n \n \n \n \n \n \n \n \n ptran_move\n \n \n \n \n \n \n \n \n \n','2023-04-04 00:07:54',4,'2023-04-04 14:21:10',4,0,NULL,NULL,NULL,'71fbb539-96d9-420c-9b3c-1edeab07e722'),(2187,'Children ARV Regimen_1stLine_4C','Children ARV Regimen_1stLine_Regimen disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4C\n Children ARV Regimen_1stLine_Regimen disaggregated by weight, sex, age\n \n 2023-07-26 13:30:34 UTC\n \n 2023-07-26 13:32:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2187\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-26 13:30:34',4,'2023-07-26 13:32:50',4,0,NULL,NULL,NULL,'f97eba59-b593-4225-8140-5bbe62c4a836'),(2188,'Children ARV Regimen_1stLine_4D','Children ARV Regimen_1stLine_4D disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4D\n Children ARV Regimen_1stLine_4D disaggregated by weight, sex, age\n \n 2023-07-26 13:30:39 UTC\n \n 2023-07-27 13:48:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2188\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-26 15:30:39',4,'2023-07-27 15:48:06',4,0,NULL,NULL,NULL,'f0f167bb-dc9e-4121-9ceb-a2268861062f'),(2189,'Children ARV Regimen_1stLine_Transition Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_Transition Data Set\n \n 2023-07-26 13:31:12 UTC\n \n 2023-08-14 12:41:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2189\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4>=35\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y10-13\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F<1y10-13\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n M1-4y10-13\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y10-13\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n','2023-07-26 13:31:12',4,'2023-08-14 12:41:44',4,0,NULL,NULL,NULL,'da04bec0-be82-45a6-9136-716f46837537'),(2190,'Children ARV Regimen_1stLine_Transition Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_Transition Data Set\n \n 2023-07-26 13:31:22 UTC\n \n 2023-08-14 13:10:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2190\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n F10-14yr35\n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6-\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-14\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr35\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-07-26 13:31:22',4,'2023-08-14 13:10:49',4,0,NULL,NULL,NULL,'5de7def7-e11b-404b-b30a-1dd8dab09558'),(2191,'Children ARV Regimen_1stLine_4E','Children ARV Regimen_1stLine_4E','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4E\n Children ARV Regimen_1stLine_4E\n \n 2023-07-28 07:21:30 UTC\n \n 2023-07-28 07:21:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2191\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-28 09:21:30',4,'2023-07-28 09:21:51',4,0,NULL,NULL,NULL,'e3824d29-b132-4875-b0a9-b5dea1536b22'),(2192,'Children ARV Regimen_1stLine_4E Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4E Data Set\n \n 2023-07-28 07:21:51 UTC\n \n 2023-08-14 15:40:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2192\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y35>=\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y35>\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y35>=\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y35>=\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n M1-4Y25-34\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y0-3\n \n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y35>=\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y35>\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y35>=\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y35>=\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n','2023-07-28 07:21:51',4,'2023-08-14 15:40:40',4,0,NULL,NULL,NULL,'27162fa8-89a6-405a-b3c2-d79250d1fa72'),(2194,'Children ARV Regimen_1stLine_4E Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4E Data Set\n \n 2023-07-28 07:29:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n \n \n','2023-07-28 09:29:51',4,NULL,NULL,0,NULL,NULL,NULL,'4c11a721-c504-4075-a7aa-68b823c3d7cb'),(2196,'Children ARV Regimen_1stLine_4F','Children ARV Regimen_1stLine_4F disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4F\n Children ARV Regimen_1stLine_4F disaggregated by weight, sex, age\n \n 2023-07-28 07:58:35 UTC\n \n 2023-07-28 07:59:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2196\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-28 09:58:35',4,'2023-07-28 09:59:11',4,0,NULL,NULL,NULL,'0ee0e4f3-4bf0-43ee-be59-cb45d9ab0328'),(2197,'Children ARV Regimen_1stLine_4F Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4F Data Set\n \n 2023-07-28 07:59:11 UTC\n \n 2023-08-14 16:08:09 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2197\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4>=35\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y0-3\n \n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-07-28 07:59:11',4,'2023-08-14 16:08:09',4,0,NULL,NULL,NULL,'88a32f53-ea23-4ad9-9673-98bde635a960'),(2198,'Children ARV Regimen_1stLine_4G','Children ARV Regimen_1stLine_4G','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4G\n Children ARV Regimen_1stLine_4G\n \n 2023-07-28 10:06:07 UTC\n \n 2023-07-28 10:06:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2198\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-28 12:06:07',4,'2023-07-28 12:06:18',4,0,NULL,NULL,NULL,'0827caea-7bbc-4d28-b47d-e04cebd43d96'),(2199,'Children ARV Regimen_1stLine_4G Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4G Data Set\n \n 2023-07-28 10:06:18 UTC\n \n 2023-08-14 16:22:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2199\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y35>=\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y35>\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y35>=\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y35>=\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y35>=\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M10-14y-25\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y0-3\n \n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y35>\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y35>=\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y24-34\n \n \n \n \n \n \n M<1y35>=\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n','2023-07-28 10:06:18',4,'2023-08-14 16:22:43',4,0,NULL,NULL,NULL,'f61713b8-60c1-48f1-bab8-d0bf3046b3e1'),(2200,'Children ARV Regimen_1stLine_4H','Children ARV Regimen_1stLine_4H','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4H\n Children ARV Regimen_1stLine_4H\n \n 2023-07-28 10:19:42 UTC\n \n 2023-07-28 10:19:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2200\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-28 12:19:42',4,'2023-07-28 12:19:49',4,0,NULL,NULL,NULL,'f672b96f-7df9-48fa-b49e-a9946b7540e8'),(2201,'Children ARV Regimen_1stLine_4H Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4H Data Set\n \n 2023-07-28 10:19:49 UTC\n \n 2023-08-14 16:43:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2201\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n F10-14yr35\n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6-\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-24\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr35\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-07-28 10:19:49',4,'2023-08-14 16:43:42',4,0,NULL,NULL,NULL,'014c9e79-d8d0-4226-8d86-869e879fb6ce'),(2202,'Children ARV Regimen_1stLine_4J',' Children ARV Regimen_1stLine_4J disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4J\n Children ARV Regimen_1stLine_4J disaggregated by weight, sex, age\n \n 2023-07-28 10:40:17 UTC\n \n 2023-07-28 10:40:24 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2202\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-28 12:40:17',4,'2023-07-28 12:40:24',4,0,NULL,NULL,NULL,'4390ec11-9cbe-42bd-888e-e681da953912'),(2203,'Children ARV Regimen_1stLine_4J Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4J Data Set\n \n 2023-07-28 10:40:24 UTC\n \n 2023-08-14 17:17:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2203\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y35>=\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y35>\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y35>=\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y35>=\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y35>=\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y35>\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y35>=\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y35>=\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n','2023-07-28 10:40:24',4,'2023-08-14 17:17:03',4,0,NULL,NULL,NULL,'b1b5ff26-4220-44b4-856e-88b7e9d39451'),(2204,'Children ARV Regimen_1stLine_4K','Children ARV Regimen_1stLine_4K disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4K\n Children ARV Regimen_1stLine_4K disaggregated by weight, sex, age\n \n 2023-07-31 11:04:52 UTC\n \n 2023-07-31 11:04:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2204\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-31 13:04:52',4,'2023-07-31 13:04:59',4,0,NULL,NULL,NULL,'635157c8-9203-475c-bc08-998a880fa244'),(2205,'Children ARV Regimen_1stLine_4K Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4K Data Set\n \n 2023-07-31 11:04:59 UTC\n \n 2023-08-14 17:30:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2205\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4>=35\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-07-31 11:04:59',4,'2023-08-14 17:30:12',4,0,NULL,NULL,NULL,'a3a4b9a1-0d71-4c08-9e4e-486f87840b6e'),(2206,'Children ARV Regimen_1stLine_4L','Children ARV Regimen_1stLine_4L','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4L\n Children ARV Regimen_1stLine_4L\n \n 2023-07-31 11:19:07 UTC\n \n 2023-07-31 11:19:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2206\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-07-31 13:19:07',4,'2023-07-31 13:19:14',4,0,NULL,NULL,NULL,'646bc981-856b-4f66-b545-eb5843952af7'),(2207,'Children ARV Regimen_1stLine_4L Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4L Data Set\n \n 2023-07-31 11:19:14 UTC\n \n 2023-08-14 17:43:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2207\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n F10-14yr35\n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6-\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-24\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr35\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-07-31 11:19:14',4,'2023-08-14 17:43:21',4,0,NULL,NULL,NULL,'f228bb0b-0af6-48b3-afeb-8b1e4e21feb3'),(2208,'Clients given 4C with >=20 copies viral load','Clients given 4C with >=20 copies viral load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with >=20 copies viral load\n Clients given 4C with >=20 copies viral load\n \n 2023-08-07 11:49:27 UTC\n \n 2023-08-14 11:19:55 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2208\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2202)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \n \n \non Active_Patients.Id = greaterThan20.Id \n)) \n \n\n','2023-08-07 11:49:27',4,'2023-08-14 11:19:55',4,0,NULL,NULL,NULL,'5a765ffd-b4ff-4899-ba79-aae76385d5d9'),(2209,'Clients given 4C with >=20 copies viral load','Clients given 4C with >=20 copies viral load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with >=20 copies viral load\n Clients given 4C with >=20 copies viral load\n \n 2023-08-07 14:15:14 UTC\n \n 2023-08-07 14:18:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2209\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 16:15:14',4,'2023-08-07 16:18:06',4,0,NULL,NULL,NULL,'6942c194-b069-44c3-a161-b77891d7f06c'),(2210,'Children ARV Regimen_1stLine_Viral_Load','Children ARV Regimen_1stLine_Viral_Load','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_Viral_Load\n Children ARV Regimen_1stLine_Viral_Load\n \n 2023-08-07 14:19:54 UTC\n \n 2023-08-08 20:10:19 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2210\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-07 16:19:54',4,'2023-08-08 22:10:19',4,0,NULL,NULL,NULL,'400088e7-a254-4fac-8a59-eac6dc9d177b'),(2211,'Children ARV Regimen_1stLine_4C_>20Copies_Viraload Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_4C_>20Copies_Viraload Data Set\n \n 2023-08-07 14:20:07 UTC\n \n 2023-08-09 09:28:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2211\n \n \n \n 4C<20\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 4C>=20\n \n \n \n \n \n \n \n \n \n 4CUndetect\n \n \n \n \n \n \n \n \n \n 4D<20\n \n \n \n \n \n \n \n \n \n 4D>=20\n \n \n \n \n \n \n \n \n \n 4DUndetect\n \n \n \n \n \n \n \n \n \n 4E<20\n \n \n \n \n \n \n \n \n \n 4E>=20\n \n \n \n \n \n \n \n \n \n 4EUndetect\n \n \n \n \n \n \n \n \n \n 4F<20\n \n \n \n \n \n \n \n \n \n 4F>=20\n \n \n \n \n \n \n \n \n \n 4FUndetect\n \n \n \n \n \n \n \n \n \n 4G<20\n \n \n \n \n \n \n \n \n \n 4G>=20\n \n \n \n \n \n \n \n \n \n 4GUndetect\n \n \n \n \n \n \n \n \n \n 4H<20\n \n \n \n \n \n \n \n \n \n 4H>=20\n \n \n \n \n \n \n \n \n \n 4HUndetect\n \n \n \n \n \n \n \n \n \n 4J<20\n \n \n \n \n \n \n \n \n \n 4J>=20\n \n \n \n \n \n \n \n \n \n 4JUndetect\n \n \n \n \n \n \n \n \n \n 4K<20\n \n \n \n \n \n \n \n \n \n 4K>=20\n \n \n \n \n \n \n \n \n \n 4KUndetect\n \n \n \n \n \n \n \n \n \n 4L<20\n \n \n \n \n \n \n \n \n \n 4L>=20\n \n \n \n \n \n \n \n \n \n 4LUndetect\n \n \n \n \n \n \n \n \n \n','2023-08-07 14:20:07',4,'2023-08-09 09:28:16',4,0,NULL,NULL,NULL,'96eef8c5-dc41-4f3f-9e62-4004c11fb291'),(2212,'Clients given 4D with >=20 Copies Viral Load','Clients given 4D with >=20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with >=20 Copies Viral Load\n Clients given 4D with >=20 Copies Viral Load\n \n 2023-08-07 14:40:38 UTC\n \n 2023-08-14 11:22:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2212\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2204)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n -- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-07 14:40:38',4,'2023-08-14 11:22:44',4,0,NULL,NULL,NULL,'41de8523-3ab9-4284-a0b1-f0298f2da510'),(2213,'Clients given 4E with >=20 Copies Viral Load','Clients given 4E with >=20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with >=20 Copies Viral Load\n Clients given 4E with >=20 Copies Viral Load\n \n 2023-08-07 14:50:06 UTC\n \n 2023-08-14 11:23:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2213\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-07 14:50:06',4,'2023-08-14 11:23:53',4,0,NULL,NULL,NULL,'c1f2fd48-a980-4af6-93f0-08598fd57995'),(2214,'Clients given 4F with >=20 copies viral load','Clients given 4F with >=20 copies viral load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with >=20 copies viral load\n Clients given 4F with >=20 copies viral load\n \n 2023-08-07 15:02:48 UTC\n \n 2023-08-14 11:29:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2214\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n -- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-07 15:02:48',4,'2023-08-14 11:29:08',4,0,NULL,NULL,NULL,'1605d858-dca2-4c0d-bb6f-967424aed8ad'),(2215,'Clients given 4H with >=20 Copies Viral Load','Clients given 4H with >=20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with >=20 Copies Viral Load\n Clients given 4H with >=20 Copies Viral Load\n \n 2023-08-07 15:11:34 UTC\n \n 2023-08-14 11:47:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2215\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n -- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-07 15:11:34',4,'2023-08-14 11:47:45',4,0,NULL,NULL,NULL,'07781cf0-2cc5-497b-b9a3-dafc63842da1'),(2216,'Clients given 4J with >=20 Copies Viral Load','Clients given 4J weighing >=20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with >=20 Copies Viral Load\n Clients given 4J weighing >=20 Copies Viral Load\n \n 2023-08-07 15:32:07 UTC\n \n 2023-08-14 11:49:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2216\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4J \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-07 15:32:07',4,'2023-08-14 11:49:33',4,0,NULL,NULL,NULL,'180f7359-ac4f-4728-ae43-8208ebf052cb'),(2217,'Clients given 4K with >=20 Copies Viral Load','Clients given 4K with >=20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with >=20 Copies Viral Load\n Clients given 4K with >=20 Copies Viral Load\n \n 2023-08-07 15:41:37 UTC\n \n 2023-08-14 11:51:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2217\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4K \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-07 15:41:37',4,'2023-08-14 11:51:49',4,0,NULL,NULL,NULL,'a5a07716-681f-44bd-84ef-391d51ace7c9'),(2218,'Clients given 4L with >=20 Copies Viral Load','Clients given 4L with >=20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with >=20 Copies Viral Load\n Clients given 4L with >=20 Copies Viral Load\n \n 2023-08-07 15:45:38 UTC\n \n 2023-08-14 11:54:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2218\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4L \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4688)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n -- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast (oss.obs_datetime) as date <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-07 15:45:38',4,'2023-08-14 11:54:05',4,0,NULL,NULL,NULL,'606f20bd-cac9-4282-a3c4-56b9f72ded30'),(2219,'Clients given 4C with <20 copies Viral Load','Clients given 4C with <20 copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with <20 copies Viral Load\n Clients given 4C with <20 copies Viral Load\n \n 2023-08-07 15:55:07 UTC\n \n 2023-08-14 11:20:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2219\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2202)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 15:55:07',4,'2023-08-14 11:20:12',4,0,NULL,NULL,NULL,'5571d546-89fc-4cda-bc4d-fab1f629ce7a'),(2220,'Clients given 4C with Undetectable Viral Load','Clients given 4C with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with Undetectable Viral Load\n Clients given 4C with Undetectable Viral Load\n \n 2023-08-07 15:57:44 UTC\n \n 2023-08-14 11:19:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2220\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n \n \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2202)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-07 15:57:44',4,'2023-08-14 11:19:40',4,0,NULL,NULL,NULL,'eaa0d4ac-c56c-4a8a-b2ca-12a462b06874'),(2221,'Clients given 4D with <20 Copies Viral Load','Clients given 4D with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with <20 Copies Viral Load\n Clients given 4D with <20 Copies Viral Load\n \n 2023-08-07 16:09:50 UTC\n \n 2023-08-14 11:23:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2221\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2204)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n -- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 16:09:50',4,'2023-08-14 11:23:00',4,0,NULL,NULL,NULL,'60e4edc3-d202-4e5c-b9d1-a4791c874209'),(2222,'Clients given 4D with Undetectable Viral Load','Clients given 4D with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with Undetectable Viral Load\n Clients given 4D with Undetectable Viral Load\n \n 2023-08-07 16:11:59 UTC\n \n 2023-08-14 11:22:23 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2222\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2204)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n -- Undetectable Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable Copies \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-07 16:11:59',4,'2023-08-14 11:22:23',4,0,NULL,NULL,NULL,'2da8e7c6-793e-42f3-994a-0dc0e72464ae'),(2223,'Clients given 4E with <20 Copies Viral Load','Clients given 4E with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with <20 Copies Viral Load\n Clients given 4E with <20 Copies Viral Load\n \n 2023-08-07 16:18:03 UTC\n \n 2023-08-14 11:26:22 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2223\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 16:18:03',4,'2023-08-14 11:26:22',4,0,NULL,NULL,NULL,'72e755a7-cbbc-4ccd-be81-7bedf125f8c4'),(2224,'Clients given 4E with Undetectable Viral Load','Clients given 4E with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with Undetectable Viral Load\n Clients given 4E with Undetectable Viral Load\n \n 2023-08-07 16:20:52 UTC\n \n 2023-08-14 12:07:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2224\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Undetectable, Viral load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-07 16:20:52',4,'2023-08-14 12:07:26',4,0,NULL,NULL,NULL,'1d7a46e2-8d42-4f34-8958-f5cf962db589'),(2225,'Clients given 4F with <20 copies viral load','Clients given 4F with <20 copies viral load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with <20 copies viral load\n Clients given 4F with <20 copies viral load\n \n 2023-08-07 16:26:02 UTC\n \n 2023-08-14 11:29:28 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2225\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 16:26:02',4,'2023-08-14 11:29:28',4,0,NULL,NULL,NULL,'3c193bb3-64d6-4b71-9069-0b53083963e2'),(2226,'Clients given 4F with Undetectable viral load','Clients given 4F with Undetectable copies viral load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with Undetectable viral load\n Clients given 4F with Undetectable copies viral load\n \n 2023-08-07 16:28:54 UTC\n \n 2023-08-14 11:28:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2226\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 16:28:54',4,'2023-08-14 11:28:42',4,0,NULL,NULL,NULL,'978dc8c8-3f02-4e20-9fb5-302be9fbf23c'),(2227,'Clients given 4G with >=20 Copies Viral Load','Clients given 4G with >=20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with >=20 Copies Viral Load\n Clients given 4G with >=20 Copies Viral Load\n \n 2023-08-07 16:32:35 UTC\n \n 2023-08-14 11:45:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2227\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-07 16:32:35',4,'2023-08-14 11:45:02',4,0,NULL,NULL,NULL,'41d9cb1b-b376-4e21-aa6c-7dce59197a97'),(2228,'Clients given 4G with <20 copies Viral_Load','Clients given 4G with <20 copies Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with <20 copies Viral_Load\n Clients given 4G with <20 copies Viral_Load\n \n 2023-08-07 16:34:54 UTC\n \n 2023-08-14 11:44:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2228\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 16:34:54',4,'2023-08-14 11:44:33',4,0,NULL,NULL,NULL,'80ebb214-6a46-4379-9a31-3e3cbbb05566'),(2229,'Clients given 4G with Undetectable Viral Load','Clients given 4G with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with Undetectable Viral Load\n Clients given 4G with Undetectable Viral Load\n \n 2023-08-07 16:39:28 UTC\n \n 2023-08-14 11:45:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2229\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- Undetectable Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable Copies \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-07 16:39:28',4,'2023-08-14 11:45:51',4,0,NULL,NULL,NULL,'d480aafa-578b-4865-bdd4-e158af437b06'),(2230,'Clients given 4H with <20 Copies Viral Load','Clients given 4H with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with <20 Copies Viral Load\n Clients given 4H with <20 Copies Viral Load\n \n 2023-08-07 16:45:29 UTC\n \n 2023-08-14 11:47:21 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2230\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 16:45:29',4,'2023-08-14 11:47:21',4,0,NULL,NULL,NULL,'5c8ddadc-a50e-4433-afb8-48e1acfc3ed5'),(2231,'Clients given 4H with Undetectable Viral Load','Clients given 4H with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with Undetectable Viral Load\n Clients given 4H with Undetectable Viral Load\n \n 2023-08-07 16:47:28 UTC\n \n 2023-08-14 11:48:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2231\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-07 16:47:28',4,'2023-08-14 11:48:07',4,0,NULL,NULL,NULL,'6d85bd5f-af27-43f5-a456-e1679230a4aa'),(2232,'Clients given 4J with <20 copies Viral Load','Clients given 4J with <20 copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with <20 copies Viral Load\n Clients given 4J with <20 copies Viral Load\n \n 2023-08-07 16:53:00 UTC\n \n 2023-08-14 11:49:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2232\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4J \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 16:53:00',4,'2023-08-14 11:49:15',4,0,NULL,NULL,NULL,'1cf1f1b1-2f40-4e5c-b55b-893716cf2a04'),(2233,'Clients given 4J with Undetectable Viral Load','Clients given 4J with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with Undetectable Viral Load\n Clients given 4J with Undetectable Viral Load\n \n 2023-08-07 16:57:27 UTC\n \n 2023-08-14 11:49:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2233\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4J \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- Undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable Copies \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-07 16:57:27',4,'2023-08-14 11:49:52',4,0,NULL,NULL,NULL,'e543fa69-cbc5-46c8-a3de-e77abcaa185a'); INSERT INTO `serialized_object` VALUES (2234,'Clients given 4K with <20 Copies Viral Load','Clients given 4K with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with <20 Copies Viral Load\n Clients given 4K with <20 Copies Viral Load\n \n 2023-08-07 17:02:35 UTC\n \n 2023-08-14 11:51:25 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2234\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4K \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 17:02:35',4,'2023-08-14 11:51:25',4,0,NULL,NULL,NULL,'54121116-3d51-4a34-ae5c-5b15f1254f6e'),(2235,'Clients given 4K with Undetectable Viral Load','Clients given 4K with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with Undetectable Viral Load\n Clients given 4K with Undetectable Viral Load\n \n 2023-08-07 17:08:26 UTC\n \n 2023-08-14 11:52:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2235\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4K \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Undetectable, Viral load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-07 17:08:26',4,'2023-08-14 11:52:08',4,0,NULL,NULL,NULL,'d2e6acfd-540a-4220-b160-b104be742043'),(2236,'Clients given 4L with <20 Copies Viral Load','Clients given 4L with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with <20 Copies Viral Load\n Clients given 4L with <20 Copies Viral Load\n \n 2023-08-07 17:13:48 UTC\n \n 2023-08-14 11:54:16 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2236\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4L \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4688)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-07 17:13:48',4,'2023-08-14 11:54:16',4,0,NULL,NULL,NULL,'d4e9e456-61f2-4e2d-8779-52e1dd59a11a'),(2237,'Clients given 4L with Undetectable Viral Load','Clients given 4L with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with Undetectable Viral Load\n Clients given 4L with Undetectable Viral Load\n \n 2023-08-07 17:17:22 UTC\n \n 2023-08-14 12:04:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2237\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4K \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4688)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Undetectable, Viral load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-07 17:17:22',4,'2023-08-14 12:04:57',4,0,NULL,NULL,NULL,'4792ce19-a4f6-4876-9a81-a7e48f279b1b'),(2238,'Clients given 4C with <20 copies Viral Load','Clients given 4C with <20 copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with <20 copies Viral Load\n Clients given 4C with <20 copies Viral Load\n \n 2023-08-07 17:40:01 UTC\n \n 2023-08-07 17:41:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2238\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 19:40:01',4,'2023-08-07 19:41:50',4,0,NULL,NULL,NULL,'523777b6-edc7-4346-abbb-1eec797d6e5c'),(2239,'Clients given 4C with Undetectable Viral_Load','Clients given 4C with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with Undetectable Viral_Load\n Clients given 4C with Undetectable Viral Load\n \n 2023-08-07 17:45:29 UTC\n \n 2023-08-07 17:54:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2239\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 19:45:29',4,'2023-08-07 19:54:18',4,0,NULL,NULL,NULL,'b3e08e0a-35ac-4b1c-86e2-2dffaa8b6ce6'),(2240,'Clients given 4D with >=20 Copies Viral Load','Clients given 4D with >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with >=20 Copies Viral Load\n Clients given 4D with >=20 Copies Viral Load\n \n 2023-08-07 17:57:17 UTC\n \n 2023-08-07 17:59:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2240\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 19:57:17',4,'2023-08-07 19:59:18',4,0,NULL,NULL,NULL,'06a65347-260a-49f6-b227-e152d369db09'),(2241,'Clients given 4D with < 20 Copies Viral Load','Clients given 4D with < 20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with < 20 Copies Viral Load\n Clients given 4D with < 20 Copies Viral Load\n \n 2023-08-07 18:00:13 UTC\n \n 2023-08-07 18:01:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2241\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:00:13',4,'2023-08-07 20:01:11',4,0,NULL,NULL,NULL,'849b9ad0-e14d-4e64-8d4d-c90f1ea85d2c'),(2242,'Clients given 4D with Undetectable Viral Load','Clients given 4D with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with Undetectable Viral Load\n Clients given 4D with Undetectable Viral Load\n \n 2023-08-07 18:02:05 UTC\n \n 2023-08-07 18:02:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2242\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:02:05',4,'2023-08-07 20:02:59',4,0,NULL,NULL,NULL,'269d7cd2-40e5-41a3-9da2-be9e310de73d'),(2243,'Clients given 4E with >=20 Copies Viral Load','Clients given 4E with >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with >=20 Copies Viral Load\n Clients given 4E with >=20 Copies Viral Load\n \n 2023-08-07 18:05:06 UTC\n \n 2023-08-07 18:06:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2243\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:05:06',4,'2023-08-07 20:06:12',4,0,NULL,NULL,NULL,'deaade8d-fa75-4774-9422-2379319a59b2'),(2244,'Clients given 4E with <20 Copies Viral Load','Clients given 4E with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with <20 Copies Viral Load\n Clients given 4E with <20 Copies Viral Load\n \n 2023-08-07 18:06:56 UTC\n \n 2023-08-07 18:08:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2244\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:06:56',4,'2023-08-07 20:08:02',4,0,NULL,NULL,NULL,'e0b2f670-7df3-4672-8411-b6d500f5f13d'),(2245,'Clients given 4E with Undetectable Viral Load','Clients given 4E with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with Undetectable Viral Load\n Clients given 4E with Undetectable Viral Load\n \n 2023-08-07 18:08:42 UTC\n \n 2023-08-07 18:10:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2245\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:08:42',4,'2023-08-07 20:10:35',4,0,NULL,NULL,NULL,'ada290e9-0105-4579-843e-a66c38a30845'),(2246,'Clients given 4F with >=20 copies viral load','Clients given 4F with >=20 copies viral load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with >=20 copies viral load\n Clients given 4F with >=20 copies viral load\n \n 2023-08-07 18:12:14 UTC\n \n 2023-08-07 18:12:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2246\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:12:14',4,'2023-08-07 20:12:59',4,0,NULL,NULL,NULL,'2755008d-c58f-4cf7-b3fb-879cb0055625'),(2247,'Clients given 4F with <20 copies Viral Load','Clients given 4F with <20 copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with <20 copies Viral Load\n Clients given 4F with <20 copies Viral Load\n \n 2023-08-07 18:13:57 UTC\n \n 2023-08-07 18:15:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2247\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:13:57',4,'2023-08-07 20:15:02',4,0,NULL,NULL,NULL,'5fd4b692-7c21-4e41-80e5-143ee6c04385'),(2248,'Clients given 4F with Undetectable Viral Load','Clients given 4F with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with Undetectable Viral Load\n Clients given 4F with Undetectable Viral Load\n \n 2023-08-07 18:15:52 UTC\n \n 2023-08-07 18:16:55 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2248\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:15:52',4,'2023-08-07 20:16:55',4,0,NULL,NULL,NULL,'9aae30ff-90c2-4228-b4a1-0aedf7354802'),(2249,'Clients given 4G with >=20 Copies Viral Load','Clients given 4G with >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with >=20 Copies Viral Load\n Clients given 4G with >=20 Copies Viral Load\n \n 2023-08-07 18:18:32 UTC\n \n 2023-08-07 18:20:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2249\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:18:32',4,'2023-08-07 20:20:58',4,0,NULL,NULL,NULL,'a602c987-a1c2-486d-93e8-2efb6a3d06d6'),(2250,'Clients given 4G with <20 copies Viral Load','Clients given 4G with <20 copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with <20 copies Viral Load\n Clients given 4G with <20 copies Viral Load\n \n 2023-08-07 18:21:47 UTC\n \n 2023-08-07 18:23:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2250\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:21:47',4,'2023-08-07 20:23:21',4,0,NULL,NULL,NULL,'6cec76ef-5466-4efe-970d-f7b76ed79e1e'),(2251,'Clients given 4G with Undetectable Viral Load','Clients given 4G with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with Undetectable Viral Load\n Clients given 4G with Undetectable Viral Load\n \n 2023-08-07 18:24:19 UTC\n \n 2023-08-07 18:25:25 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2251\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:24:19',4,'2023-08-07 20:25:25',4,0,NULL,NULL,NULL,'ef8cbe9f-0742-4531-8dbe-1efbfc9c807a'),(2252,'Clients given 4H with >=20 Copies Viral Load','Clients given 4H with >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with >=20 Copies Viral Load\n Clients given 4H with >=20 Copies Viral Load\n \n 2023-08-07 18:26:08 UTC\n \n 2023-08-07 18:27:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2252\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:26:08',4,'2023-08-07 20:27:36',4,0,NULL,NULL,NULL,'f374ad0c-24ca-460e-8ed4-812fcdbb8b30'),(2253,'Clients given 4H weighing <20 Copies Viral Load','Clients given 4H weighing <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H weighing <20 Copies Viral Load\n Clients given 4H weighing <20 Copies Viral Load\n \n 2023-08-07 18:32:51 UTC\n \n 2023-08-07 18:34:47 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2253\n COUNT\n \n \n \n \n endDate\n ${startDate}\n \n \n location\n ${location}\n \n \n startDate\n ${endDate}\n \n \n \n','2023-08-07 20:32:51',4,'2023-08-07 20:34:47',4,0,NULL,NULL,NULL,'981353f5-77cf-4e9e-b418-96ba27b38c0d'),(2254,'Clients given 4H with Undetectable Viral Load','Clients given 4H with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with Undetectable Viral Load\n Clients given 4H with Undetectable Viral Load\n \n 2023-08-07 18:35:38 UTC\n \n 2023-08-07 18:36:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2254\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:35:38',4,'2023-08-07 20:36:30',4,0,NULL,NULL,NULL,'3cff4201-9093-4de5-a526-4c714a0e4b75'),(2255,'Clients given 4J weighing >=20 Copies Viral Load','Clients given 4J weighing >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J weighing >=20 Copies Viral Load\n Clients given 4J weighing >=20 Copies Viral Load\n \n 2023-08-07 18:37:43 UTC\n \n 2023-08-07 18:38:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2255\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:37:43',4,'2023-08-07 20:38:52',4,0,NULL,NULL,NULL,'ccd5a99e-b517-45c0-864c-d3c6f4ef6701'),(2256,'Clients given 4J with <20 copies Viral Load','Clients given 4J with <20 copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with <20 copies Viral Load\n Clients given 4J with <20 copies Viral Load\n \n 2023-08-07 18:40:26 UTC\n \n 2023-08-07 18:41:37 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2256\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:40:26',4,'2023-08-07 20:41:37',4,0,NULL,NULL,NULL,'99531929-455a-4092-b2e9-48993920a7b3'),(2257,'Clients given 4J with Undetectable Viral Load','Clients given 4J with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with Undetectable Viral Load\n Clients given 4J with Undetectable Viral Load\n \n 2023-08-07 18:42:19 UTC\n \n 2023-08-07 18:45:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2257\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:42:19',4,'2023-08-07 20:45:10',4,0,NULL,NULL,NULL,'059ea6c5-c8bf-42ba-abbf-50b8bd27f0e1'),(2258,'Clients given 4K with >=20 Copies Viral Load','Clients given 4K with >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with >=20 Copies Viral Load\n Clients given 4K with >=20 Copies Viral Load\n \n 2023-08-07 18:46:10 UTC\n \n 2023-08-07 18:47:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2258\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:46:10',4,'2023-08-07 20:47:00',4,0,NULL,NULL,NULL,'4d992a61-8cc5-4846-afd1-605e939b3f6e'),(2259,'Clients given 4K with <20 Copies Viral Load','Clients given 4K with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with <20 Copies Viral Load\n Clients given 4K with <20 Copies Viral Load\n \n 2023-08-07 18:48:35 UTC\n \n 2023-08-08 10:02:48 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2259\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:48:35',4,'2023-08-08 12:02:48',4,0,NULL,NULL,NULL,'a1388a42-9e0b-4057-9343-515ab7744a3a'),(2260,'Clients given 4K with Undetectable Viral Load','Clients given 4K with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with Undetectable Viral Load\n Clients given 4K with Undetectable Viral Load\n \n 2023-08-07 18:50:00 UTC\n \n 2023-08-07 18:50:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2260\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:50:00',4,'2023-08-07 20:50:42',4,0,NULL,NULL,NULL,'50081155-8d33-4ece-ad03-825e8f26f54b'),(2261,'Clients given 4L weighing >=20 Copies Viral Load','Clients given 4L weighing >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L weighing >=20 Copies Viral Load\n Clients given 4L weighing >=20 Copies Viral Load\n \n 2023-08-07 18:51:33 UTC\n \n 2023-08-07 18:52:55 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2261\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:51:33',4,'2023-08-07 20:52:55',4,0,NULL,NULL,NULL,'44e7920f-d834-4397-ba46-342d70d2d351'),(2262,'Clients given 4L with <20 Copies Viral Load','Clients given 4L with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with <20 Copies Viral Load\n Clients given 4L with <20 Copies Viral Load\n \n 2023-08-07 18:54:15 UTC\n \n 2023-08-07 18:54:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2262\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:54:15',4,'2023-08-07 20:54:59',4,0,NULL,NULL,NULL,'a46689e8-87db-4b2e-b627-fa3a695e9e49'),(2263,'Clients given 4L with Undetectable Viral Load','Clients given 4L with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with Undetectable Viral Load\n Clients given 4L with Undetectable Viral Load\n \n 2023-08-07 18:55:39 UTC\n \n 2023-08-07 18:56:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2263\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-07 20:55:39',4,'2023-08-07 20:56:21',4,0,NULL,NULL,NULL,'38640382-c5f2-4174-b4b6-e05863aea4b8'),(2264,'Clients given 4C with good adherence','Clients given 4C with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with good adherence\n Clients given 4C with good adherence\n \n 2023-08-09 09:38:59 UTC\n \n 2023-08-14 10:41:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2264\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2202)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:38:59',4,'2023-08-14 10:41:15',4,0,NULL,NULL,NULL,'80eda8e4-4432-4308-92bc-9c4a6d5835ba'),(2265,'Clients given 4D with good adherence','Clients given 4D with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with good adherence\n Clients given 4D with good adherence\n \n 2023-08-09 09:40:40 UTC\n \n 2023-08-14 10:43:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2265\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2204)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:40:40',4,'2023-08-14 10:43:07',4,0,NULL,NULL,NULL,'50e6ed7b-8da6-420e-b00d-c5a7a6e8e618'),(2266,'Clients given 4E with good adherence','Clients given 4E with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with good adherence\n Clients given 4E with good adherence\n \n 2023-08-09 09:40:58 UTC\n \n 2023-08-14 10:45:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2266\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:40:58',4,'2023-08-14 10:45:49',4,0,NULL,NULL,NULL,'c9adbf40-4d5f-4ca4-b388-4a4ee5c16f3e'),(2267,'Clients given 4F with good adherence','Clients given 4F with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with good adherence\n Clients given 4F with good adherence\n \n 2023-08-09 09:49:16 UTC\n \n 2023-08-14 10:57:13 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2267\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:49:16',4,'2023-08-14 10:57:13',4,0,NULL,NULL,NULL,'691b7d00-855b-4869-8938-9502f8762962'),(2268,'Clients given 4G with good adherence','Clients given 4G with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with good adherence\n Clients given 4G with good adherence\n \n 2023-08-09 09:49:37 UTC\n \n 2023-08-14 10:58:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2268\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:49:37',4,'2023-08-14 10:58:30',4,0,NULL,NULL,NULL,'d0f8da5f-e6aa-44af-9980-cd882429e8ac'),(2269,'Clients given 4H with good adherence','Clients given 4H with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with good adherence\n Clients given 4H with good adherence\n \n 2023-08-09 09:49:55 UTC\n \n 2023-08-14 11:00:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2269\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:49:55',4,'2023-08-14 11:00:32',4,0,NULL,NULL,NULL,'90332338-8e76-4563-a7f1-f3f67ffa8f3b'),(2270,'Clients given 4J with good adherence','Clients given 4J with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with good adherence\n Clients given 4J with good adherence\n \n 2023-08-09 09:54:49 UTC\n \n 2023-08-14 11:09:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2270\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4J \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:54:49',4,'2023-08-14 11:09:02',4,0,NULL,NULL,NULL,'888d3fd4-ad2c-4e7e-b07f-8c68a08ed1f4'),(2271,'Clients given 4K with good adherence','Clients given 4K with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with good adherence\n Clients given 4K with good adherence\n \n 2023-08-09 09:55:07 UTC\n \n 2023-08-14 11:10:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2271\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4K \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:55:07',4,'2023-08-14 11:10:40',4,0,NULL,NULL,NULL,'def70332-aae8-450d-8e78-2b3f83574bc9'),(2272,'Clients given 4L with good adherence','Clients given 4L with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with good adherence\n Clients given 4L with good adherence\n \n 2023-08-09 09:55:23 UTC\n \n 2023-08-14 11:14:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2272\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4L \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4688)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-09 09:55:23',4,'2023-08-14 11:14:33',4,0,NULL,NULL,NULL,'7d1751a3-47c6-406a-a631-90ed96f37660'),(2273,'clients given 4C with fair adherence','clients given 4C with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 4C with fair adherence\n clients given 4C with fair adherence\n \n 2023-08-09 10:04:32 UTC\n \n 2023-08-14 10:40:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2273\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2202)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:04:32',4,'2023-08-14 10:40:15',4,0,NULL,NULL,NULL,'15494d8b-bc16-4865-8561-a0f11bb906f5'),(2274,'clients given 4D with fair adherence','clients given 4D with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 4D with fair adherence\n clients given 4D with fair adherence\n \n 2023-08-09 10:04:52 UTC\n \n 2023-08-14 10:42:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2274\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2204)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:04:52',4,'2023-08-14 10:42:43',4,0,NULL,NULL,NULL,'3076328f-0cf6-496f-bcfc-ec00585bf8f7'),(2275,'clients given 4E with fair adherence','clients given 4E with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 4E with fair adherence\n clients given 4E with fair adherence\n \n 2023-08-09 10:05:09 UTC\n \n 2023-08-14 10:45:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2275\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:05:09',4,'2023-08-14 10:45:35',4,0,NULL,NULL,NULL,'8c441fe9-1c2f-4eba-9e14-3c13b7d0e22d'),(2276,'clients given 4F with fair adherence','clients given 4F with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 4F with fair adherence\n clients given 4F with fair adherence\n \n 2023-08-09 10:08:17 UTC\n \n 2023-08-14 10:56:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2276\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:08:17',4,'2023-08-14 10:56:58',4,0,NULL,NULL,NULL,'cb6f6a66-39fa-4584-8ad9-397be4e8acc0'),(2277,'clients given 4G with fair adherence','clients given 4G with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 4G with fair adherence\n clients given 4G with fair adherence\n \n 2023-08-09 10:09:12 UTC\n \n 2023-08-14 10:58:17 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2277\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:09:12',4,'2023-08-14 10:58:17',4,0,NULL,NULL,NULL,'456a7189-4a16-40fa-9702-abf6b2e8b707'),(2278,'Clients given 4H with fair adherence','Clients given 4H with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with fair adherence\n Clients given 4H with fair adherence\n \n 2023-08-09 10:10:29 UTC\n \n 2023-08-14 11:00:09 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2278\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:10:29',4,'2023-08-14 11:00:09',4,0,NULL,NULL,NULL,'3cb85e60-1a5e-422c-b0af-fc15c8ba62ed'),(2279,'Clients given 4K with fair adherence','Clients given 4K with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with fair adherence\n Clients given 4K with fair adherence\n \n 2023-08-09 10:17:56 UTC\n \n 2023-08-14 11:10:04 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2279\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4K \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:17:56',4,'2023-08-14 11:10:04',4,0,NULL,NULL,NULL,'cbd5b84d-066f-41a6-bd8b-bc81dc23c99d'),(2280,'Clients given 4J with fair adherence','Clients given 4J with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with fair adherence\n Clients given 4J with fair adherence\n \n 2023-08-09 10:18:17 UTC\n \n 2023-08-14 11:08:38 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2280\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4J \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:18:17',4,'2023-08-14 11:08:38',4,0,NULL,NULL,NULL,'14b826bd-9709-497b-a02d-8fa8d4146faa'),(2281,'Clients given 4L with fair adherence','Clients given 4L with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with fair adherence\n Clients given 4L with fair adherence\n \n 2023-08-09 10:21:31 UTC\n \n 2023-08-14 11:14:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2281\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4L \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-09 10:21:31',4,'2023-08-14 11:14:18',4,0,NULL,NULL,NULL,'62b94203-c51d-456f-87a6-dd15791f3d71'),(2282,'Clients given 4C with poor adherence','Clients given 4C with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with poor adherence\n Clients given 4C with poor adherence\n \n 2023-08-09 10:45:41 UTC\n \n 2023-08-09 10:49:23 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2282\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 20 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2202)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:45:41',4,'2023-08-09 10:49:23',4,0,NULL,NULL,NULL,'769d8c15-f519-440d-acaf-e2640e2409bc'),(2283,'Clients given 4D with poor adherence','Clients given 4D with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with poor adherence\n Clients given 4D with poor adherence\n \n 2023-08-09 10:46:02 UTC\n \n 2023-08-14 10:41:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2283\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 2204)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:46:02',4,'2023-08-14 10:41:45',4,0,NULL,NULL,NULL,'f77a67fe-ac10-4c92-ab0c-98a5b4dfd5f1'),(2284,'Clients given 4E with poor adherence','Clients given 4E with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with poor adherence\n Clients given 4E with poor adherence\n \n 2023-08-09 10:46:19 UTC\n \n 2023-08-14 10:45:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2284\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3679)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:46:19',4,'2023-08-14 10:45:20',4,0,NULL,NULL,NULL,'2eb584f9-1fbe-4c98-adec-b2feb88933b7'),(2285,'Clients given 4F with poor adherence','Clients given 4F with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with poor adherence\n Clients given 4F with poor adherence\n \n 2023-08-09 10:50:41 UTC\n \n 2023-08-14 10:57:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2285\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3680)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:50:41',4,'2023-08-14 10:57:32',4,0,NULL,NULL,NULL,'3c5012df-c0bf-411b-a7d1-da092ade8986'),(2286,'Clients given 4G with poor adherence','Clients given 4G with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with poor adherence\n Clients given 4G with poor adherence\n \n 2023-08-09 10:50:56 UTC\n \n 2023-08-14 10:58:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2286\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4684)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:50:56',4,'2023-08-14 10:58:45',4,0,NULL,NULL,NULL,'cdee04fe-950f-4b39-88bf-9736744da52f'),(2287,'Clients given 4H with poor adherence','Clients given 4H with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with poor adherence\n Clients given 4H with poor adherence\n \n 2023-08-09 10:51:12 UTC\n \n 2023-08-14 11:00:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2287\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4685)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:51:12',4,'2023-08-14 11:00:59',4,0,NULL,NULL,NULL,'9a9175d4-c8ad-439e-b484-edb2345816ad'),(2288,'Clients given 4L with poor adherence','Clients given 4L with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with poor adherence\n Clients given 4L with poor adherence\n \n 2023-08-09 10:55:46 UTC\n \n 2023-08-14 11:14:48 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2288\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4L \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4688)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:55:46',4,'2023-08-14 11:14:48',4,0,NULL,NULL,NULL,'5b38ffa0-ea56-4cda-b3cf-03d1b83e7889'),(2289,'Clients given 4K with poor adherence','Clients given 4K with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with poor adherence\n Clients given 4K with poor adherence\n \n 2023-08-09 10:56:07 UTC\n \n 2023-08-14 11:10:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2289\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4K \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:56:07',4,'2023-08-14 11:10:52',4,0,NULL,NULL,NULL,'1c393c0d-a2e3-4223-9b24-848d235e7a19'),(2290,'Clients given 4J with poor adherence','Clients given 4J with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with poor adherence\n Clients given 4J with poor adherence\n \n 2023-08-09 10:56:28 UTC\n \n 2023-08-14 11:09:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2290\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 4J \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-09 10:56:28',4,'2023-08-14 11:09:18',4,0,NULL,NULL,NULL,'47569cef-3b90-4fbf-9558-b7a4afb195ab'),(2291,'Children ARV Regimen_1stLine_Adherence','Children ARV Regimen_1stLine_Adherence','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_Adherence\n Children ARV Regimen_1stLine_Adherence\n \n 2023-08-09 19:25:53 UTC\n \n 2023-08-09 19:26:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2291\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-09 19:25:53',4,'2023-08-09 19:26:39',4,0,NULL,NULL,NULL,'dcdcb494-6ca6-47a5-aaac-92decc868c82'),(2292,'Children ARV Regimen_1stLine_Adherence Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_Adherence Data Set\n \n 2023-08-09 19:26:39 UTC\n \n 2023-08-10 09:42:22 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2292\n \n \n \n 4C_fair\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 4C_good\n \n \n \n \n \n \n \n \n \n 4C_poor\n \n \n \n \n \n \n \n \n \n 4D_fair\n \n \n \n \n \n \n \n \n \n 4D_good\n \n \n \n \n \n \n \n \n \n 4D_poor\n \n \n \n \n \n \n \n \n \n 4E_fair\n \n \n \n \n \n \n \n \n \n 4E_good\n \n \n \n \n \n \n \n \n \n 4E_poor\n \n \n \n \n \n \n \n \n \n 4F_fair\n \n \n \n \n \n \n \n \n \n 4F_good\n \n \n \n \n \n \n \n \n \n 4F_poor\n \n \n \n \n \n \n \n \n \n 4G_fair\n \n \n \n \n \n \n \n \n \n 4G_good\n \n \n \n \n \n \n \n \n \n 4G_poor\n \n \n \n \n \n \n \n \n \n 4H_fair\n \n \n \n \n \n \n \n \n \n 4H_good\n \n \n \n \n \n \n \n \n \n 4H_poor\n \n \n \n \n \n \n \n \n \n 4J_fair\n \n \n \n \n \n \n \n \n \n 4J_good\n \n \n \n \n \n \n \n \n \n 4J_poor\n \n \n \n \n \n \n \n \n \n 4K_fair\n \n \n \n \n \n \n \n \n \n 4K_good\n \n \n \n \n \n \n \n \n \n 4K_poor\n \n \n \n \n \n \n \n \n \n 4L_fair\n \n \n \n \n \n \n \n \n \n 4L_good\n \n \n \n \n \n \n \n \n \n 4L_poor\n \n \n \n \n \n \n \n \n \n','2023-08-09 19:26:39',4,'2023-08-10 09:42:22',4,0,NULL,NULL,NULL,'129f4cce-9154-4509-8649-9b3ed22fe029'),(2293,'Clients given 4C with good adherence','Clients given 4C with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with good adherence\n Clients given 4C with good adherence\n \n 2023-08-09 19:34:37 UTC\n \n 2023-08-09 19:40:19 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2293\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:34:37',4,'2023-08-09 19:40:19',4,0,NULL,NULL,NULL,'9aebf6da-cf9b-45ed-bbdd-861ff4c0fd41'),(2294,'Clients given 4C with fair adherence','Clients given 4C with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with fair adherence\n Clients given 4C with fair adherence\n \n 2023-08-09 19:34:50 UTC\n \n 2023-08-09 19:39:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2294\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:34:50',4,'2023-08-09 19:39:36',4,0,NULL,NULL,NULL,'ae06dd89-8f3d-4448-bab9-212196f1660d'),(2295,'Clients given 4C with poor adherence','Clients given 4C with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4C with poor adherence\n Clients given 4C with poor adherence\n \n 2023-08-09 19:35:01 UTC\n \n 2023-08-09 19:39:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2295\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:35:01',4,'2023-08-09 19:39:57',4,0,NULL,NULL,NULL,'88e3d929-46c6-4698-b83e-81552c4b0078'),(2296,'Clients given 4D with good adherence','Clients given 4D with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with good adherence\n Clients given 4D with good adherence\n \n 2023-08-09 19:43:04 UTC\n \n 2023-08-09 19:46:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2296\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:43:04',4,'2023-08-09 19:46:08',4,0,NULL,NULL,NULL,'7b0d9987-2436-479b-b186-682878585356'),(2297,'Clients given 4D with fair adherence','Clients given 4D with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with fair adherence\n Clients given 4D with fair adherence\n \n 2023-08-09 19:43:10 UTC\n \n 2023-08-09 19:46:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2297\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:43:10',4,'2023-08-09 19:46:35',4,0,NULL,NULL,NULL,'6e70eb0d-55a5-4cc0-b79e-4e80bf25978d'),(2298,'Clients given 4D with poor adherence','Clients given 4D with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with poor adherence\n Clients given 4D with poor adherence\n \n 2023-08-09 19:43:23 UTC\n \n 2023-08-09 19:47:01 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2298\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:43:23',4,'2023-08-09 19:47:01',4,0,NULL,NULL,NULL,'dde54d37-4aab-443f-9b40-2fe211fc296a'),(2299,'Clients given 4E with good adherence','Clients given 4E with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with good adherence\n Clients given 4E with good adherence\n \n 2023-08-09 19:47:57 UTC\n \n 2023-08-09 19:52:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2299\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:47:57',4,'2023-08-09 19:52:12',4,0,NULL,NULL,NULL,'8572efe5-f3ea-463f-8abf-fe4086a2aaf7'),(2300,'clients given 4E with fair adherence','Clients given 4E with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 4E with fair adherence\n Clients given 4E with fair adherence\n \n 2023-08-09 19:48:21 UTC\n \n 2023-08-09 19:53:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2300\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:48:21',4,'2023-08-09 19:53:51',4,0,NULL,NULL,NULL,'9157aa83-9a8f-4598-933d-06a98e849b9c'),(2301,'Clients given 4E with poor adherence','Clients given 4E with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4E with poor adherence\n Clients given 4E with poor adherence\n \n 2023-08-09 19:49:01 UTC\n \n 2023-08-09 19:54:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2301\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:49:01',4,'2023-08-09 19:54:14',4,0,NULL,NULL,NULL,'134c2069-3e31-41df-8845-18839686bfba'),(2302,'Clients given 4F with good adherence','Clients given 4F with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with good adherence\n Clients given 4F with good adherence\n \n 2023-08-09 19:55:08 UTC\n \n 2023-08-09 19:57:55 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2302\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:55:08',4,'2023-08-09 19:57:55',4,0,NULL,NULL,NULL,'d6358532-78d0-4095-9fcb-edf9bc09f548'),(2303,'clients given 4F with fair adherence','clients given 4F with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 4F with fair adherence\n clients given 4F with fair adherence\n \n 2023-08-09 19:55:30 UTC\n \n 2023-08-09 19:59:24 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2303\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:55:30',4,'2023-08-09 19:59:24',4,0,NULL,NULL,NULL,'25550508-c457-4534-9385-9c35fe182a5e'),(2304,'Clients given 4F with poor adherence','Clients given 4F with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4F with poor adherence\n Clients given 4F with poor adherence\n \n 2023-08-09 19:56:13 UTC\n \n 2023-08-09 19:59:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2304\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 19:56:13',4,'2023-08-09 19:59:49',4,0,NULL,NULL,NULL,'de1988bb-4fda-4d70-b77a-569364cb3880'),(2305,'Clients given 4G with good adherence','Clients given 4G with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with good adherence\n Clients given 4G with good adherence\n \n 2023-08-09 20:00:32 UTC\n \n 2023-08-09 20:04:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2305\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:00:32',4,'2023-08-09 20:04:29',4,0,NULL,NULL,NULL,'f15e2c6d-1a13-45c8-b80e-33982967f9ee'),(2306,'Clients given 4G with poor adherence','Clients given 4G with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4G with poor adherence\n Clients given 4G with poor adherence\n \n 2023-08-09 20:01:35 UTC\n \n 2023-08-09 20:05:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2306\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:01:35',4,'2023-08-09 20:05:36',4,0,NULL,NULL,NULL,'9b6c2db1-dea2-4afa-b20c-391c4985795c'),(2307,'clients given 4G with fair adherence','clients given 4G with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n clients given 4G with fair adherence\n clients given 4G with fair adherence\n \n 2023-08-09 20:01:43 UTC\n \n 2023-08-09 20:04:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2307\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:01:43',4,'2023-08-09 20:04:58',4,0,NULL,NULL,NULL,'b7856cf5-f989-45fd-8da6-f0ba354e3e96'),(2308,'Clients given 4H with good adherence','Clients given 4H with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with good adherence\n Clients given 4H with good adherence\n \n 2023-08-09 20:06:49 UTC\n \n 2023-08-09 20:10:41 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2308\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:06:49',4,'2023-08-09 20:10:41',4,0,NULL,NULL,NULL,'cfb7a7c6-30e8-4f10-a55b-faff56674767'),(2309,'Clients given 4H with fair adherence','Clients given 4H with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with fair adherence\n Clients given 4H with fair adherence\n \n 2023-08-09 20:07:01 UTC\n \n 2023-08-09 20:10:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2309\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:07:01',4,'2023-08-09 20:10:57',4,0,NULL,NULL,NULL,'5df6e5f1-3116-49e6-a896-df143af3004e'),(2310,'Clients given 4H with poor adherence','Clients given 4H with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4H with poor adherence\n Clients given 4H with poor adherence\n \n 2023-08-09 20:07:57 UTC\n \n 2023-08-09 20:13:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2310\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:07:57',4,'2023-08-09 20:13:06',4,0,NULL,NULL,NULL,'65132fb3-cc4a-4859-8cbf-2f26ad87c444'),(2311,'Clients given 4J with fair adherence','Clients given 4J with fair adherence\r\n','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with fair adherence\n Clients given 4J with fair adherence \n\n \n 2023-08-09 20:13:40 UTC\n \n 2023-08-09 20:17:28 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2311\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:13:40',4,'2023-08-09 20:17:28',4,0,NULL,NULL,NULL,'7396bec4-26e5-46ae-9751-217c77d66d44'),(2312,'Clients given 4J with good adherence','Clients given 4J with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with good adherence\n Clients given 4J with good adherence\n \n 2023-08-09 20:13:48 UTC\n \n 2023-08-09 20:17:09 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2312\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:13:48',4,'2023-08-09 20:17:09',4,0,NULL,NULL,NULL,'b7ecce5a-9011-4c8a-a77b-538d579acf4a'),(2313,'Clients given 4J with poor adherence','Clients given 4J with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4J with poor adherence\n Clients given 4J with poor adherence\n \n 2023-08-09 20:14:07 UTC\n \n 2023-08-09 20:17:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2313\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:14:07',4,'2023-08-09 20:17:52',4,0,NULL,NULL,NULL,'21d68248-3137-4f24-89b3-702c4c86b258'),(2314,'Clients given 4K with good adherence','Clients given 4K with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with good adherence\n Clients given 4K with good adherence\n \n 2023-08-09 20:19:21 UTC\n \n 2023-08-09 20:22:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2314\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:19:21',4,'2023-08-09 20:22:30',4,0,NULL,NULL,NULL,'898b11a3-3876-45bc-a327-207de5a91288'),(2315,'Clients given 4K with fair adherence','Clients given 4K with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with fair adherence\n Clients given 4K with fair adherence\n \n 2023-08-09 20:19:40 UTC\n \n 2023-08-09 20:23:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2315\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:19:40',4,'2023-08-09 20:23:00',4,0,NULL,NULL,NULL,'01cd007c-98e1-4a76-91a3-35dde1c4b25b'),(2316,'Clients given 4K with poor adherence','Clients given 4K with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4K with poor adherence\n Clients given 4K with poor adherence\n \n 2023-08-09 20:20:07 UTC\n \n 2023-08-09 20:23:47 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2316\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:20:07',4,'2023-08-09 20:23:47',4,0,NULL,NULL,NULL,'4feeb398-2818-460e-8e2c-3df8a27c5c68'),(2317,'Clients given 4L with good adherence','Clients given 4L with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with good adherence\n Clients given 4L with good adherence\n \n 2023-08-09 20:25:36 UTC\n \n 2023-08-09 20:29:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2317\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:25:36',4,'2023-08-09 20:29:06',4,0,NULL,NULL,NULL,'6f28a61d-320a-49a5-8bf5-fc9e9c68cf5e'),(2318,'Clients given 4L with fair adherence','Clients given 4L with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with fair adherence\n Clients given 4L with fair adherence\n \n 2023-08-09 20:25:55 UTC\n \n 2023-08-09 20:29:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2318\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:25:55',4,'2023-08-09 20:29:26',4,0,NULL,NULL,NULL,'58759e6a-e8d0-4eca-9a01-610e7d2f27c6'),(2319,'Clients given 4L with poor adherence','Clients given 4L with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4L with poor adherence\n Clients given 4L with poor adherence\n \n 2023-08-09 20:26:12 UTC\n \n 2023-08-09 20:29:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2319\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-09 20:26:12',4,'2023-08-09 20:29:45',4,0,NULL,NULL,NULL,'3dfc43b9-8bf9-4833-890a-88876f8da47c'),(2321,'Children ARV Regimen_2ndLine_5A','Children ARV Regimen_2ndLine_5A disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5A\n Children ARV Regimen_2ndLine_5A disaggregated by weight, sex, age\n \n 2023-08-15 17:48:13 UTC\n \n 2023-08-15 19:23:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2321\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-15 19:48:13',4,'2023-08-15 21:23:02',4,0,NULL,NULL,NULL,'37b51d3f-838d-4211-aced-12371e6a7493'),(2322,'Children ARV Regimen_1stLine_5A Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_5A Data Set\n \n 2023-08-15 17:48:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n \n \n','2023-08-15 19:48:21',4,NULL,NULL,0,NULL,NULL,NULL,'6b9d88ee-8215-4be6-89f5-2b6dbec7d979'),(2323,'Children ARV Regimen_1stLine_5A Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_1stLine_5A Data Set\n \n 2023-08-15 17:48:43 UTC\n \n 2023-08-16 10:53:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2323\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F1-4y>=35\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-08-15 19:48:43',4,'2023-08-16 12:53:15',4,0,NULL,NULL,NULL,'1311fb91-2a90-44c5-876f-0bf0284580f4'),(2324,'Children ARV Regimen_3rdLine_6A','Children ARV Regimen_3rdLine_6A disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6A\n Children ARV Regimen_3rdLine_6A disaggregated by weight, sex, age\n \n 2023-08-15 19:27:09 UTC\n \n 2023-08-15 19:27:54 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2324\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-15 21:27:09',4,'2023-08-15 21:27:54',4,0,NULL,NULL,NULL,'2478792b-752a-4b20-97f7-5033810e1ba8'),(2325,'Children ARV Regimen_3rdLine_6A Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6A Data Set\n \n 2023-08-15 19:27:54 UTC\n \n 2023-08-15 21:23:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2325\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6\n \n \n \n \n \n \n F10-14yr>=\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-24\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M10-14yr>=\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-08-15 21:27:54',4,'2023-08-15 23:23:05',4,0,NULL,NULL,NULL,'0e0b0b1e-e085-4f4f-af07-c44587b0d8f2'),(2326,'Children ARV Regimen_2ndLine_5B','Children ARV Regimen_2ndLine_5B disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5B\n Children ARV Regimen_2ndLine_5B disaggregated by weight, sex, age\n \n 2023-08-15 19:42:04 UTC\n \n 2023-08-15 19:42:28 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2326\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-15 21:42:04',4,'2023-08-15 21:42:28',4,0,NULL,NULL,NULL,'85cddf9e-e519-40f9-9df5-e1d36c7c2b27'),(2327,'Children ARV Regimen_2ndLine_5B Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5B Data Set\n \n 2023-08-15 19:42:28 UTC\n \n 2023-08-16 10:02:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2327\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F1-4y>=35\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-14\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-08-15 21:42:28',4,'2023-08-16 12:02:14',4,0,NULL,NULL,NULL,'b217699a-cf93-4478-8b85-8f59939d020a'),(2328,'Children ARV Regimen_3rdLine_6B ','Children ARV Regimen_3rdLine_6B disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6B \n Children ARV Regimen_3rdLine_6B disaggregated by weight, sex, age\n \n 2023-08-16 08:51:49 UTC\n \n 2023-08-16 08:53:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2328\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 10:51:49',4,'2023-08-16 10:53:21',4,0,NULL,NULL,NULL,'1f0f9f2c-575a-462f-be70-5b8774c58cd6'),(2329,'Children ARV Regimen_3rdLine_6B Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6B Data Set\n \n 2023-08-16 08:53:21 UTC\n \n 2023-08-16 11:15:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2329\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6-\n \n \n \n \n \n \n F10-14yr>=\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-24\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M10-14yr>=\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-08-16 10:53:21',4,'2023-08-16 13:15:59',4,0,NULL,NULL,NULL,'983588a7-5b66-41ef-ad94-a32596694717'),(2330,'HIV Lost To Follow Up','HIV patients who have not been seen for at least 18 months','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV Lost To Follow Up\n HIV patients who have not been seen for at least 18 months\n \n 2023-08-16 09:25:57 UTC\n \n \n lastExecutionTime\n \n java.util.Date\n true\n \n \n \n \n /* \n * Name:HIV Lost To Follow Up \n * Query Type: SQL Cohort Query \n * Description: HIV patients who have not been seen for at least 18 months \n * Assumption: Database has only HIV patients \n * HIV Case Reporting Module has already excluded patients previously added to the list. \n */ \n \n SELECT e2.patient_id \n FROM ( \n SELECT e1.patient_id, max(e1.encounter_datetime) as latest_encounter_date \n FROM encounter e1 \n WHERE not e1.voided \n GROUP BY e1.patient_id \n ) as e2 \n WHERE \n date(e2.latest_encounter_date) <= DATE_SUB(now(), INTERVAL 18 MONTH) \n AND \n date(e2.latest_encounter_date) > DATE_SUB(:lastExecutionTime, INTERVAL 18 MONTH); \n\n','2023-08-16 11:25:57',2,NULL,NULL,0,NULL,NULL,NULL,'8916dca2-85b6-4eea-b921-d5cffe1056d4'),(2331,'HIV Patient Died','HIV patients who have died','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HIV Patient Died\n HIV patients who have died\n \n 2023-08-16 09:25:57 UTC\n \n \n lastExecutionTime\n \n java.util.Date\n true\n \n \n \n \n /* \n * Name:HIV Patient Died \n * Query Type: SQL Cohort Query \n * Description: HIV patients who have died \n * Assumption: Database has only HIV patients \n * HIV Case Reporting Module has already excluded patients previously added to the list. \n */ \n \n SELECT person_id \n FROM person \n WHERE dead = 1 \n AND( \n date_created >= date(:lastExecutionTime) \n OR date_changed >= date(:lastExecutionTime) \n ) \n AND not voided; \n\n','2023-08-16 11:25:57',2,NULL,NULL,0,NULL,NULL,NULL,'d8cb3c40-0d86-4448-8f1f-cf4cd91ece26'),(2333,'Children ARV Regimen_2ndLine_5C','Children ARV Regimen_2ndLine_5C disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5C\n Children ARV Regimen_2ndLine_5C disaggregated by weight, sex, age\n \n 2023-08-16 10:14:20 UTC\n \n 2023-08-16 10:14:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2333\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 12:14:20',4,'2023-08-16 12:14:36',4,0,NULL,NULL,NULL,'38a458f9-cb42-4eb7-9b3a-22be06efe0e5'),(2334,'Children ARV Regimen_2ndLine_5C Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5C Data Set\n \n 2023-08-16 10:14:27 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n \n \n','2023-08-16 12:14:27',4,NULL,NULL,0,NULL,NULL,NULL,'2d670708-bd88-4e83-b9fa-9a0b6d137ea1'),(2335,'Children ARV Regimen_2ndLine_5C Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5C Data Set\n \n 2023-08-16 10:14:36 UTC\n \n 2023-08-16 11:42:37 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2335\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F1-4y>=35\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-9\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y24-34\n \n \n \n \n \n \n M<1y5-9\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-08-16 12:14:36',4,'2023-08-16 13:42:37',4,0,NULL,NULL,NULL,'5add0ab6-3850-4623-ad50-8f5d30ba2df9'),(2336,'Children ARV Regimen_2ndLine_5D','Children ARV Regimen_2ndLine_5D disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5D\n Children ARV Regimen_2ndLine_5D disaggregated by weight, sex, age\n \n 2023-08-16 11:00:11 UTC\n \n 2023-08-16 11:00:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2336\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 13:00:11',4,'2023-08-16 13:00:49',4,0,NULL,NULL,NULL,'3a4943e7-3026-4e28-b345-26acb4012006'),(2337,'Children ARV Regimen_2ndLine_5D Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5D Data Set\n \n 2023-08-16 11:00:49 UTC\n \n 2023-08-16 14:46:17 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2337\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F1-4y>=35\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-08-16 13:00:49',4,'2023-08-16 16:46:17',4,0,NULL,NULL,NULL,'51fbe59a-77f3-40b1-9d18-e90e9cd9cacc'),(2338,'Children ARV Regimen_3rdLine_6C','Children ARV Regimen_3rdLine_6C disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6C\n Children ARV Regimen_3rdLine_6C disaggregated by weight, sex, age\n \n 2023-08-16 11:26:46 UTC\n \n 2023-08-16 11:27:31 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2338\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 13:26:46',4,'2023-08-16 13:27:31',4,0,NULL,NULL,NULL,'61228d0f-b944-4ccc-ba45-d47ecd58c914'),(2339,'Children ARV Regimen_3rdLine_6C Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6C Data Set\n \n 2023-08-16 11:27:31 UTC\n \n 2023-08-16 12:37:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2339\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6-\n \n \n \n \n \n \n F10-14yr>=\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-24\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M10-14yr>=\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-08-16 13:27:31',4,'2023-08-16 14:37:59',4,0,NULL,NULL,NULL,'4a1d329b-6eeb-4ef7-a104-d1c6f9479abc'),(2342,'Children ARV Regimen_2ndLine_5E','Children ARV Regimen_2ndLine_5E disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5E\n Children ARV Regimen_2ndLine_5E disaggregated by weight, sex, age\n \n 2023-08-16 11:51:18 UTC\n \n 2023-08-16 11:52:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2342\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 13:51:18',4,'2023-08-16 13:52:18',4,0,NULL,NULL,NULL,'f710c498-9264-4d7e-bdb4-e846dec7972b'),(2343,'Children ARV Regimen_2ndLine_5E Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5E Data Set\n \n 2023-08-16 11:51:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n \n \n','2023-08-16 13:51:29',4,NULL,NULL,0,NULL,NULL,NULL,'8eaa5921-d13d-4bd9-912d-d9d09af7394f'),(2344,'Children ARV Regimen_2ndLine_5E Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5E Data Set\n \n 2023-08-16 11:52:09 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n \n \n','2023-08-16 13:52:09',4,NULL,NULL,0,NULL,NULL,NULL,'0105c46c-76ef-4088-b5b1-b89e42dc49d1'),(2345,'Children ARV Regimen_2ndLine_5E Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5E Data Set\n \n 2023-08-16 11:52:18 UTC\n \n 2023-08-16 15:02:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2345\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F1-4y>=35\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F6-9y4-5\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y0-3\n \n \n \n \n \n \n F<1y10-13\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Adults\n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-08-16 13:52:18',4,'2023-08-16 17:02:44',4,0,NULL,NULL,NULL,'3b422368-2868-4d7f-a24f-936289c1b8a2'),(2346,'Children ARV Regimen_3rdLine_6D','Children ARV Regimen_3rdLine_6D disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6D\n Children ARV Regimen_3rdLine_6D disaggregated by weight, sex, age\n \n 2023-08-16 14:30:52 UTC\n \n 2023-08-16 14:31:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2346\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 16:30:52',4,'2023-08-16 16:31:03',4,0,NULL,NULL,NULL,'7f66540d-c280-4dd8-a771-71057ff7ce42'),(2347,'Children ARV Regimen_3rdLine_6D Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6D Data Set\n \n 2023-08-16 14:31:03 UTC\n \n 2023-08-16 15:52:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2347\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6-\n \n \n \n \n \n \n F10-14yr>=\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-24\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M10-14yr>=\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-08-16 16:31:03',4,'2023-08-16 17:52:50',4,0,NULL,NULL,NULL,'27ae096d-4997-4d00-a00a-390c70159a12'),(2348,'Children ARV Regimen_2ndLine_5F','Children ARV Regimen_2ndLine_5F disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5F\n Children ARV Regimen_2ndLine_5F disaggregated by weight, sex, age\n \n 2023-08-16 14:55:10 UTC\n \n 2023-08-16 14:55:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2348\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 16:55:10',4,'2023-08-16 16:55:33',4,0,NULL,NULL,NULL,'9d77bcc5-cf55-4f71-8e9b-77d19d82e10d'),(2349,'Children ARV Regimen_2ndLine_5F Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5F Data Set\n \n 2023-08-16 14:55:33 UTC\n \n 2023-08-16 15:48:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2349\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F1-4y>=35\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-08-16 16:55:33',4,'2023-08-16 17:48:02',4,0,NULL,NULL,NULL,'dc690b7d-b448-4f9f-b159-00d2671710e6'),(2350,'Children ARV Regimen_2ndLine_5G','Children ARV Regimen_2ndLine_5G','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5G\n Children ARV Regimen_2ndLine_5G\n \n 2023-08-16 15:09:07 UTC\n \n 2023-08-16 15:10:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2350\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 17:09:07',4,'2023-08-16 17:10:08',4,0,NULL,NULL,NULL,'f2f7b2a9-f96e-4f72-8edf-5e0a4195ec85'),(2351,'Children ARV Regimen_2ndLine_5G Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5G Data Set\n \n 2023-08-16 15:10:08 UTC\n \n 2023-08-16 18:01:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2351\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F1-4y>=35\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n \n \n \n M10-14>=35\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y0-3\n \n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-08-16 17:10:08',4,'2023-08-16 20:01:10',4,0,NULL,NULL,NULL,'1041fe73-c2e7-47db-8d84-eb79176e25fe'),(2352,'Children ARV Regimen_2ndLine_5H','Children ARV Regimen_2ndLine_5H disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5H\n Children ARV Regimen_2ndLine_5H disaggregated by weight, sex, age\n \n 2023-08-16 15:50:48 UTC\n \n 2023-08-16 15:50:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2352\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 17:50:48',4,'2023-08-16 17:50:59',4,0,NULL,NULL,NULL,'71b6899d-048d-4c2a-a10f-84422454ece6'),(2353,'Children ARV Regimen_2ndLine_5H Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_5H Data Set\n \n 2023-08-16 15:50:59 UTC\n \n 2023-08-16 17:19:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2353\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4y0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4y10-13\n \n \n \n \n \n \n \n \n \n F1-4y14-19\n \n \n \n \n \n \n \n \n \n F1-4y20-24\n \n \n \n \n \n \n \n \n \n F1-4y25-34\n \n \n \n \n \n \n \n \n \n F1-4y4-5\n \n \n \n \n \n \n \n \n \n F1-4y6-9\n \n \n \n \n \n \n \n \n \n F1-4y>=35\n \n \n \n \n \n \n \n \n \n F10-14y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14y10-\n \n \n \n \n \n \n F10-14y14-\n \n \n \n \n \n \n F10-14y20-\n \n \n \n \n \n \n F10-14y25-\n \n \n \n \n \n \n F10-14y4-5\n \n \n \n \n \n \n F10-14y6-9\n \n \n \n \n \n \n F10-14y>=3\n \n \n \n \n \n \n \n \n \n F5-9y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9y10-13\n \n \n \n \n \n \n F5-9y14-19\n \n \n \n \n \n \n F5-9y20-24\n \n \n \n \n \n \n F5-9y25-34\n \n \n \n \n \n \n F5-9y4-5\n \n \n \n \n \n \n F5-9y6-9\n \n \n \n \n \n \n F5-9y>=35\n \n \n \n \n \n \n F<1y0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1y10-13\n \n \n \n \n \n \n \n \n \n F<1y14-19\n \n \n \n \n \n \n F<1y20-24\n \n \n \n \n \n \n F<1y25-34\n \n \n \n \n \n \n F<1y4-5\n \n \n \n \n \n \n F<1y6-9\n \n \n \n \n \n \n F<1y>=35\n \n \n \n \n \n \n M1-4y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4y10-13\n \n \n \n \n \n \n M1-4y14-19\n \n \n \n \n \n \n M1-4y20-24\n \n \n \n \n \n \n M1-4y25-34\n \n \n \n \n \n \n M1-4y4-5\n \n \n \n \n \n \n M1-4y6-9\n \n \n \n \n \n \n M1-4y>=35\n \n \n \n \n \n \n M10-14y0-3\n \n \n \n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14y10-\n \n \n \n \n \n \n M10-14y14-\n \n \n \n \n \n \n \n \n \n M10-14y20-\n \n \n \n \n \n \n M10-14y25-\n \n \n \n \n \n \n M10-14y4-5\n \n \n \n \n \n \n M10-14y6-9\n \n \n \n \n \n \n M10-14y>=3\n \n \n \n \n \n \n M5-9y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9y10-13\n \n \n \n \n \n \n M5-9y14-19\n \n \n \n \n \n \n M5-9y20-24\n \n \n \n \n \n \n M5-9y25-34\n \n \n \n \n \n \n M5-9y4-5\n \n \n \n \n \n \n \n \n \n M5-9y6-9\n \n \n \n \n \n \n M5-9y>=35\n \n \n \n \n \n \n M<1y0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1y10-13\n \n \n \n \n \n \n M<1y14-19\n \n \n \n \n \n \n M<1y20-24\n \n \n \n \n \n \n M<1y25-34\n \n \n \n \n \n \n M<1y4-5\n \n \n \n \n \n \n M<1y6-9\n \n \n \n \n \n \n M<1y>=35\n \n \n \n \n \n \n','2023-08-16 17:50:59',4,'2023-08-16 19:19:35',4,0,NULL,NULL,NULL,'fa79bb1e-c2a3-435f-8074-de92d79ed741'),(2354,'Children ARV Regimen_3rdLine_6E','Children ARV Regimen_3rdLine_6E disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6E\n Children ARV Regimen_3rdLine_6E disaggregated by weight, sex, age\n \n 2023-08-16 15:57:11 UTC\n \n 2023-08-16 15:58:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2354\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 17:57:11',4,'2023-08-16 17:58:30',4,0,NULL,NULL,NULL,'ace827f2-1783-4eac-819e-12793a2c4e9f'),(2355,'Children ARV Regimen_3rdLine_6E Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6E Data Set\n \n 2023-08-16 15:58:30 UTC\n \n 2023-08-16 17:28:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2355\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6-\n \n \n \n \n \n \n F10-14yr>=\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-24\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M10-14yr>=\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-08-16 17:58:30',4,'2023-08-16 19:28:59',4,0,NULL,NULL,NULL,'91b72368-e321-4a7b-968d-1271493fa958'),(2356,'Children ARV Regimen_3rdLine_6F','Children ARV Regimen_3rdLine_6F disaggregated by weight, sex, age','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6F\n Children ARV Regimen_3rdLine_6F disaggregated by weight, sex, age\n \n 2023-08-16 17:30:28 UTC\n \n 2023-08-16 17:30:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2356\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-16 19:30:28',4,'2023-08-16 19:30:40',4,0,NULL,NULL,NULL,'cba2a95d-5060-47fd-9401-a826e1c0858a'),(2357,'Children ARV Regimen_3rdLine_6F Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_6F Data Set\n \n 2023-08-16 17:30:39 UTC\n \n 2023-08-16 18:09:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2357\n \n \n DM_Sex\n \n \n \n \n \n \n DM_Age\n \n \n \n \n endDate\n ${endDate}\n \n \n \n \n \n \n \n F1-4yr0-3\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n F1-4yr10-1\n \n \n \n \n \n \n \n \n \n F1-4yr14-1\n \n \n \n \n \n \n \n \n \n F1-4yr20-2\n \n \n \n \n \n \n \n \n \n F1-4yr25-3\n \n \n \n \n \n \n \n \n \n F1-4yr4-5\n \n \n \n \n \n \n \n \n \n F1-4yr6-9\n \n \n \n \n \n \n \n \n \n F1-4yr>=35\n \n \n \n \n \n \n \n \n \n F10-14yr0-\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n F10-14yr10\n \n \n \n \n \n \n F10-14yr14\n \n \n \n \n \n \n F10-14yr20\n \n \n \n \n \n \n F10-14yr25\n \n \n \n \n \n \n F10-14yr4-\n \n \n \n \n \n \n F10-14yr6-\n \n \n \n \n \n \n F10-14yr>=\n \n \n \n \n \n \n F5-9yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n F5-9yr10-1\n \n \n \n \n \n \n F5-9yr14-1\n \n \n \n \n \n \n F5-9yr20-2\n \n \n \n \n \n \n F5-9yr25-3\n \n \n \n \n \n \n F5-9yr4-5\n \n \n \n \n \n \n F5-9yr6-9\n \n \n \n \n \n \n F5-9yr>=35\n \n \n \n \n \n \n F<1yr0-3\n \n \n \n \n DM_Sex\n Females\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n F<1yr10-13\n \n \n \n \n \n \n F<1yr14-19\n \n \n \n \n \n \n F<1yr20-24\n \n \n \n \n \n \n F<1yr25-34\n \n \n \n \n \n \n F<1yr4-5\n \n \n \n \n \n \n F<1yr6-9\n \n \n \n \n \n \n F<1yr>=35\n \n \n \n \n \n \n M1-4yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 01to04yrs\n \n \n \n \n \n M1-4yr10-1\n \n \n \n \n \n \n M1-4yr14-1\n \n \n \n \n \n \n M1-4yr20-2\n \n \n \n \n \n \n M1-4yr25-3\n \n \n \n \n \n \n M1-4yr4-5\n \n \n \n \n \n \n M1-4yr6-9\n \n \n \n \n \n \n M1-4yr>=35\n \n \n \n \n \n \n M10-14yr0-\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 10to14yrs\n \n \n \n \n \n M10-14yr10\n \n \n \n \n \n \n M10-14yr14\n \n \n \n \n \n \n M10-14yr20\n \n \n \n \n \n \n M10-14yr25\n \n \n \n \n \n \n M10-14yr4-\n \n \n \n \n \n \n M10-14yr6-\n \n \n \n \n \n \n M10-14yr>=\n \n \n \n \n \n \n M5-9yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n 05to09yrs\n \n \n \n \n \n M5-9yr10-1\n \n \n \n \n \n \n M5-9yr14-1\n \n \n \n \n \n \n M5-9yr20-2\n \n \n \n \n \n \n M5-9yr25-3\n \n \n \n \n \n \n M5-9yr4-5\n \n \n \n \n \n \n M5-9yr6-9\n \n \n \n \n \n \n M5-9yr>=35\n \n \n \n \n \n \n M<1yr0-3\n \n \n \n \n DM_Sex\n Males\n \n \n DM_Age\n Under 1yr\n \n \n \n \n \n M<1yr10-13\n \n \n \n \n \n \n M<1yr14-19\n \n \n \n \n \n \n M<1yr20-24\n \n \n \n \n \n \n M<1yr25-34\n \n \n \n \n \n \n M<1yr4-5\n \n \n \n \n \n \n M<1yr6-9\n \n \n \n \n \n \n M<1yr>=35\n \n \n \n \n \n \n','2023-08-16 19:30:39',4,'2023-08-16 20:09:14',4,0,NULL,NULL,NULL,'739d18c0-8b69-47f2-b49c-f203e776d528'); INSERT INTO `serialized_object` VALUES (2358,'Clients given 5A with >=20Copies_Viral_Load','Clients given 5A with >=20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A with >=20Copies_Viral_Load\n Clients given 5A with >=20Copies_Viral_Load\n \n 2023-08-17 08:33:38 UTC\n \n 2023-08-17 08:34:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2358\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5A \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \n \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 10:33:38',4,'2023-08-17 10:34:00',4,0,NULL,NULL,NULL,'f9c21dfa-e2bc-4174-858c-5290ee412c83'),(2359,'Clients given 5A with <20Copies_Viral_Load','Clients given 5A with <20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A with <20Copies_Viral_Load\n Clients given 5A with <20Copies_Viral_Load\n \n 2023-08-17 08:35:33 UTC\n \n 2023-08-17 08:36:23 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2359\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5A \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 10:35:33',4,'2023-08-17 10:36:23',4,0,NULL,NULL,NULL,'f803bb84-0a18-4319-91e7-4ea289d8a295'),(2360,'Clients given 5A with Undetectable_Viral_Load','Clients given 5A with Undetectable_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A with Undetectable_Viral_Load\n Clients given 5A with Undetectable_Viral_Load\n \n 2023-08-17 08:37:56 UTC\n \n 2023-08-17 08:39:04 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2360\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5A \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 10:37:56',4,'2023-08-17 10:39:04',4,0,NULL,NULL,NULL,'2386a884-ae79-46a7-8adf-d5044b06e9c4'),(2361,'Clients given 5B with >=20Copies_Viral_Load','Clients given 5B with >=20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B with >=20Copies_Viral_Load\n Clients given 5B with >=20Copies_Viral_Load\n \n 2023-08-17 08:44:15 UTC\n \n 2023-08-17 09:02:37 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2361\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5B \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \n \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 10:44:15',4,'2023-08-17 11:02:37',4,0,NULL,NULL,NULL,'5939e332-e3fc-4a42-a736-b647f31a87a3'),(2362,'Clients given 5B with <20Copies_Viral_Load','Clients given 5B with <20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B with <20Copies_Viral_Load\n Clients given 5B with <20Copies_Viral_Load\n \n 2023-08-17 08:59:37 UTC\n \n 2023-08-17 09:05:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2362\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5B \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 10:59:37',4,'2023-08-17 11:05:50',4,0,NULL,NULL,NULL,'8b4f6f3d-4444-4429-ac84-94ecc1e14ba2'),(2363,'Clients given 5B with Undetectable_Viral_Load','Clients given 5B with Undetectable_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B with Undetectable_Viral_Load\n Clients given 5B with Undetectable_Viral_Load\n \n 2023-08-17 09:06:53 UTC\n \n 2023-08-17 09:07:37 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2363\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5B \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n)) \n \n\n','2023-08-17 11:06:53',4,'2023-08-17 11:07:37',4,0,NULL,NULL,NULL,'d7418afd-aca2-46e9-9c72-e920d447db27'),(2364,'Clients given 5C with >=20Copies_Viral_Load','Clients given 5C with >=20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C with >=20Copies_Viral_Load\n Clients given 5C with >=20Copies_Viral_Load\n \n 2023-08-17 09:13:04 UTC\n \n 2023-08-17 09:15:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2364\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4696)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 11:13:04',4,'2023-08-17 11:15:46',4,0,NULL,NULL,NULL,'ee32f98e-445e-4a15-8a1e-c594ad7729b3'),(2365,'Clients given 5C with <20Copies_Viral_Load','Clients given 5C with <20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C with <20Copies_Viral_Load\n Clients given 5C with <20Copies_Viral_Load\n \n 2023-08-17 09:18:17 UTC\n \n 2023-08-17 09:19:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2365\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4696)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 11:18:17',4,'2023-08-17 11:19:06',4,0,NULL,NULL,NULL,'5fc6059b-5dca-4e92-abe4-e44c4e5f9f09'),(2366,'Clients given 5C with Undetectable Viral Load','Clients given 5C with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C with Undetectable Viral Load\n Clients given 5C with Undetectable Viral Load\n \n 2023-08-17 09:20:42 UTC\n \n 2023-08-17 09:21:13 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2366\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4696)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 11:20:42',4,'2023-08-17 11:21:13',4,0,NULL,NULL,NULL,'f3e6450c-1bda-42b4-87d3-352e65c53612'),(2367,'Clients given 5D with >=20Copies_Viral_Load','Clients given 5D with >=20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D with >=20Copies_Viral_Load\n Clients given 5D with >=20Copies_Viral_Load\n \n 2023-08-17 09:31:21 UTC\n \n 2023-08-17 09:32:04 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2367\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4697)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 11:31:21',4,'2023-08-17 11:32:04',4,0,NULL,NULL,NULL,'25589972-ceb9-4c56-bb7c-2911f712e272'),(2368,'Clients given 5D with <20Copies_Viral_Load','Clients given 5D with <20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D with <20Copies_Viral_Load\n Clients given 5D with <20Copies_Viral_Load\n \n 2023-08-17 09:34:28 UTC\n \n 2023-08-17 09:36:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2368\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4697)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 11:34:28',4,'2023-08-17 11:36:20',4,0,NULL,NULL,NULL,'a9a60d85-6eba-4872-9b0c-02c941d7ff94'),(2369,'Clients given 4D with poor adherence','Clients given 4D with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 4D with poor adherence\n Clients given 4D with poor adherence\n \n 2023-08-17 09:51:32 UTC\n \n','2023-08-17 11:51:32',4,NULL,NULL,0,NULL,NULL,NULL,'76e21882-219e-4852-aca2-a0d774c1c79b'),(2370,'Clients given 5a with poor adherence','Clients given 5a with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a with poor adherence\n Clients given 5a with poor adherence\n \n 2023-08-17 09:51:59 UTC\n \n 2023-08-17 09:53:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2370\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5a \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 11:51:59',4,'2023-08-17 11:53:44',4,0,NULL,NULL,NULL,'67dd544b-2e27-408f-824b-0312d06e9785'),(2371,'Clients given 5a with fair adherence','Clients given 5a with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a with fair adherence\n Clients given 5a with fair adherence\n \n 2023-08-17 09:56:02 UTC\n \n 2023-08-17 09:56:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2371\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5a \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 11:56:02',4,'2023-08-17 11:56:33',4,0,NULL,NULL,NULL,'93e07039-5627-49fd-9fb4-9f3cf8ddaafd'),(2372,'Clients given 5a with good adherence','Clients given 5a with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a with good adherence\n Clients given 5a with good adherence\n \n 2023-08-17 09:57:50 UTC\n \n 2023-08-17 09:58:24 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2372\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5a \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3681)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 11:57:50',4,'2023-08-17 11:58:24',4,0,NULL,NULL,NULL,'94df16c2-5336-419b-be14-fe6c390dc41b'),(2373,'Clients given 5D with Undetectable Viral Load','Clients given 5D with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D with Undetectable Viral Load\n Clients given 5D with Undetectable Viral Load\n \n 2023-08-17 09:58:03 UTC\n \n 2023-08-17 09:58:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2373\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4697)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 11:58:03',4,'2023-08-17 11:58:42',4,0,NULL,NULL,NULL,'95abcfbb-daac-4a02-a38c-455f5f0aca2d'),(2374,'Clients given 5E with >=20Copies_Viral_Load','Clients given 5E with >=20Copies_Viral_Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E with >=20Copies_Viral_Load\n Clients given 5E with >=20Copies_Viral_Load\n \n 2023-08-17 10:05:15 UTC\n \n 2023-08-17 10:05:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2374\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4698)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 12:05:15',4,'2023-08-17 12:05:33',4,0,NULL,NULL,NULL,'7ec09187-6a9d-403e-97c3-f7d85f2a16a2'),(2375,'Clients given 5E with <20 Copies Viral Load','Clients given 5E with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E with <20 Copies Viral Load\n Clients given 5E with <20 Copies Viral Load\n \n 2023-08-17 10:06:47 UTC\n \n 2023-08-17 10:09:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2375\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4698)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 12:06:47',4,'2023-08-17 12:09:36',4,0,NULL,NULL,NULL,'fc0384af-2aba-4967-94cf-351c49ff4c06'),(2376,'Clients given 5b with fair adherence','Clients given 5b with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5b with fair adherence\n Clients given 5b with fair adherence\n \n 2023-08-17 10:10:23 UTC\n \n 2023-08-17 10:12:23 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2376\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5b \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 12:10:23',4,'2023-08-17 12:12:23',4,0,NULL,NULL,NULL,'efbcc56c-18cd-4533-980c-6d8cf1c02e23'),(2377,'Clients given 5E with Undetectable Viral Load','Clients given 5E with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E with Undetectable Viral Load\n Clients given 5E with Undetectable Viral Load\n \n 2023-08-17 10:10:47 UTC\n \n 2023-08-17 10:11:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2377\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4698)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 12:10:47',4,'2023-08-17 12:11:44',4,0,NULL,NULL,NULL,'c1b14868-35fc-4ced-b9d6-d7434dbe4b96'),(2378,'Clients given 5b with good adherence','Clients given 5b with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5b with good adherence\n Clients given 5b with good adherence\n \n 2023-08-17 10:14:15 UTC\n \n 2023-08-17 10:15:01 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2378\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5b \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 12:14:15',4,'2023-08-17 12:15:01',4,0,NULL,NULL,NULL,'602e0915-bb58-4b03-a63e-ed3a6f83cc33'),(2379,'Clients given 5b with poor adherence','Clients given 5b with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5b with poor adherence\n Clients given 5b with poor adherence\n \n 2023-08-17 10:20:28 UTC\n \n 2023-08-17 10:24:24 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2379\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5b \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3682)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 12:20:28',4,'2023-08-17 12:24:24',4,0,NULL,NULL,NULL,'02a6a90c-a410-4c5e-a32f-a56f6dad4a49'),(2380,'Clients given 5F with >=20Copies Viral Load','Clients given 5F with >=20Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F with >=20Copies Viral Load\n Clients given 5F with >=20Copies Viral Load\n \n 2023-08-17 10:20:38 UTC\n \n 2023-08-17 10:22:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2380\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4699)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n (SELECT weight_.Id, _weight \n from \n (select oss.person_id as Id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_numeric)), 20) as _weight \n from obs oss \n where oss.concept_id = 119 and oss.voided=0 \n and oss.obs_datetime <= cast(:endDate as date) \n group by oss.person_id)AS weight_ \n where _weight >= 20 and _weight <= 24.9)peads_weight \n ON Active_Patients.Id = peads_weight.Id \n \n)) \n \n\n','2023-08-17 12:20:38',4,'2023-08-17 12:22:29',4,0,NULL,NULL,NULL,'ed92d4db-077e-4eae-9c2c-963d455b9df3'),(2381,'Clients given 5F with <20 Copies Viral Load','Clients given 5F with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F with <20 Copies Viral Load\n Clients given 5F with <20 Copies Viral Load\n \n 2023-08-17 10:27:57 UTC\n \n 2023-08-17 10:34:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2381\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4699)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 12:27:57',4,'2023-08-17 12:34:06',4,0,NULL,NULL,NULL,'9ca8ee52-584e-4164-85a0-73c3afffa236'),(2382,'Clients given 5F with Undetectable Viral Load','Clients given 5F with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F with Undetectable Viral Load\n Clients given 5F with Undetectable Viral Load\n \n 2023-08-17 10:36:35 UTC\n \n 2023-08-17 10:37:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2382\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4699)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 12:36:35',4,'2023-08-17 12:37:44',4,0,NULL,NULL,NULL,'fddbb793-03b3-432b-aa85-1afddec431d9'),(2383,'Clients given 5c with poor adherence','Clients given 5c with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5c with poor adherence\n Clients given 5c with poor adherence\n \n 2023-08-17 10:39:09 UTC\n \n 2023-08-17 10:40:19 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2383\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5c \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4696)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 12:39:09',4,'2023-08-17 12:40:19',4,0,NULL,NULL,NULL,'15d7e4f8-1626-4a98-ae7d-494e2cb6f49b'),(2384,'Clients given 5G with >=20Copies Viral Load','Clients given 5G with >=20Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G with >=20Copies Viral Load\n Clients given 5G with >=20Copies Viral Load\n \n 2023-08-17 10:42:06 UTC\n \n 2023-08-17 10:42:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2384\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4700)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 12:42:06',4,'2023-08-17 12:42:29',4,0,NULL,NULL,NULL,'2a249734-89d9-4f4c-bcab-dff2815d3b58'),(2385,'Clients given 5c with fair adherence','Clients given 5c with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5c with fair adherence\n Clients given 5c with fair adherence\n \n 2023-08-17 10:42:21 UTC\n \n 2023-08-17 10:43:23 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2385\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5c \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4696)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 12:42:21',4,'2023-08-17 12:43:23',4,0,NULL,NULL,NULL,'4d26e5f3-76e3-49fc-8a3c-f5de81a7724d'),(2386,'Clients given 5G with <20 Copies Viral Load','Clients given 5G with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G with <20 Copies Viral Load\n Clients given 5G with <20 Copies Viral Load\n \n 2023-08-17 10:45:37 UTC\n \n 2023-08-17 10:48:38 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2386\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4700)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 12:45:37',4,'2023-08-17 12:48:38',4,0,NULL,NULL,NULL,'353bb356-a392-4c21-8641-40fd092426ce'),(2387,'Clients given 5c with good adherence','Clients given 5c with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5c with good adherence\n Clients given 5c with good adherence\n \n 2023-08-17 10:56:34 UTC\n \n 2023-08-17 10:57:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2387\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5c \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4696)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 12:56:34',4,'2023-08-17 12:57:29',4,0,NULL,NULL,NULL,'3f30f547-9fa6-4336-b034-e79a64906b6c'),(2388,'Clients given 5G with Undetectable Viral Load','Clients given 5G with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G with Undetectable Viral Load\n Clients given 5G with Undetectable Viral Load\n \n 2023-08-17 10:58:06 UTC\n \n 2023-08-17 10:58:41 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2388\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5G \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4700)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 12:58:06',4,'2023-08-17 12:58:41',4,0,NULL,NULL,NULL,'7cb7f18e-986e-4854-be48-ca51e1d753dc'),(2389,'Clients given 5d with poor adherence','Clients given 5d with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5d with poor adherence\n Clients given 5d with poor adherence\n \n 2023-08-17 11:03:17 UTC\n \n 2023-08-17 11:03:56 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2389\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4697)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 13:03:17',4,'2023-08-17 13:03:56',4,0,NULL,NULL,NULL,'77c59203-be56-4041-abaf-eb409f199aab'),(2390,'Clients given 5d with fair adherence','Clients given 5d with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5d with fair adherence\n Clients given 5d with fair adherence\n \n 2023-08-17 11:06:27 UTC\n \n 2023-08-17 11:07:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2390\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4697)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 13:06:27',4,'2023-08-17 13:07:15',4,0,NULL,NULL,NULL,'33ef5391-29b2-426b-bb43-75f88df81f18'),(2391,'Clients given 5H with >=20Copies Viral Load','Clients given 5H with >=20Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H with >=20Copies Viral Load\n Clients given 5H with >=20Copies Viral Load\n \n 2023-08-17 11:06:39 UTC\n \n 2023-08-17 11:07:19 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2391\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4701)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 13:06:39',4,'2023-08-17 13:07:19',4,0,NULL,NULL,NULL,'a6c02fb1-c931-4405-9dcd-1fa775e9d262'),(2392,':Clients given 5d with good adherence',':Clients given 5d with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n :Clients given 5d with good adherence\n :Clients given 5d with good adherence\n \n 2023-08-17 11:08:05 UTC\n \n 2023-08-17 11:08:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2392\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4697)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 13:08:05',4,'2023-08-17 13:08:51',4,0,NULL,NULL,NULL,'478a65e7-cbfc-4d04-bcbf-e97ad2119117'),(2393,'Clients given 5H with <20 Copies Viral Load','Clients given 5H with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H with <20 Copies Viral Load\n Clients given 5H with <20 Copies Viral Load\n \n 2023-08-17 11:08:35 UTC\n \n 2023-08-17 11:09:13 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2393\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4701)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 13:08:35',4,'2023-08-17 13:09:13',4,0,NULL,NULL,NULL,'92d662a9-7c9c-4d7f-8105-7892cc50f8df'),(2394,'Clients given 5H with Undetectable Viral Load','Clients given 5H with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H with Undetectable Viral Load\n Clients given 5H with Undetectable Viral Load\n \n 2023-08-17 11:10:21 UTC\n \n 2023-08-17 11:12:04 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2394\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5H \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4701)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 13:10:21',4,'2023-08-17 13:12:04',4,0,NULL,NULL,NULL,'67ad52ec-1ca8-4bd4-977e-cb0930173888'),(2395,'Clients given 5e with poor adherence','Clients given 5e with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5e with poor adherence\n Clients given 5e with poor adherence\n \n 2023-08-17 11:11:53 UTC\n \n 2023-08-17 11:12:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2395\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5e \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4698)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 13:11:53',4,'2023-08-17 13:12:26',4,0,NULL,NULL,NULL,'13802910-1107-47fe-82b8-60340f77abef'),(2396,'Clients given 5e with fair adherence','Clients given 5e with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5e with fair adherence\n Clients given 5e with fair adherence\n \n 2023-08-17 11:13:19 UTC\n \n 2023-08-17 11:13:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2396\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5e \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4698)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 13:13:19',4,'2023-08-17 13:13:43',4,0,NULL,NULL,NULL,'6585614b-c405-4fe5-bcb0-8edae5825b41'),(2397,'Clients given 5e with good adherence','Clients given 5e with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5e with good adherence\n Clients given 5e with good adherence\n \n 2023-08-17 11:17:29 UTC\n \n 2023-08-17 11:18:09 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2397\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5e \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4698)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 13:17:29',4,'2023-08-17 13:18:09',4,0,NULL,NULL,NULL,'dc9c0189-b91f-4b80-a484-67e2f5b4005c'),(2398,'Clients given 6A with >=20Copies Viral Load','Clients given 6A with >=20Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A with >=20Copies Viral Load\n Clients given 6A with >=20Copies Viral Load\n \n 2023-08-17 11:19:05 UTC\n \n 2023-08-17 11:19:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2398\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6A \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 13:19:05',4,'2023-08-17 13:19:35',4,0,NULL,NULL,NULL,'b0f47001-fdc3-4ea5-be0c-00112fab3bc8'),(2399,'Clients given 6A with <20 Copies Viral Load','Clients given 6A with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A with <20 Copies Viral Load\n Clients given 6A with <20 Copies Viral Load\n \n 2023-08-17 11:21:31 UTC\n \n 2023-08-17 11:22:34 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2399\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6A \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n \n)) \n \n\n','2023-08-17 13:21:31',4,'2023-08-17 13:22:34',4,0,NULL,NULL,NULL,'b912ab78-0fb9-4639-a1f4-56f1e6b2e44e'),(2400,'Clients given 6A with Undetectable Viral Load','Clients given 6A with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A with Undetectable Viral Load\n Clients given 6A with Undetectable Viral Load\n \n 2023-08-17 11:23:42 UTC\n \n 2023-08-17 11:24:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2400\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6A \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n \n)) \n \n\n','2023-08-17 13:23:42',4,'2023-08-17 13:24:21',4,0,NULL,NULL,NULL,'2801df34-8bcf-4a7b-bc89-1210ad3d727d'),(2401,'Clients given 5f with poor adherence','Clients given 5f with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5f with poor adherence\n Clients given 5f with poor adherence\n \n 2023-08-17 11:26:41 UTC\n \n 2023-08-17 11:27:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2401\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5f \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4699)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 13:26:41',4,'2023-08-17 13:27:36',4,0,NULL,NULL,NULL,'c0c6a92f-87ed-4149-85af-4ed2e31328ac'),(2402,'Clients given 6B with >=20Copies Viral Load','Clients given 6B with >=20Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B with >=20Copies Viral Load\n Clients given 6B with >=20Copies Viral Load\n \n 2023-08-17 11:27:26 UTC\n \n 2023-08-17 11:31:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2402\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6B \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 13:27:26',4,'2023-08-17 13:31:50',4,0,NULL,NULL,NULL,'c01f687e-baef-4589-b4fd-63abfc132991'),(2403,'Clients given 6B with <20 Copies Viral Load','Clients given 6B with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B with <20 Copies Viral Load\n Clients given 6B with <20 Copies Viral Load\n \n 2023-08-17 11:29:39 UTC\n \n 2023-08-17 11:30:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2403\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6B \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 13:29:39',4,'2023-08-17 13:30:18',4,0,NULL,NULL,NULL,'f6a13155-22a3-4ecc-80bf-dfef935ebf86'),(2404,'Clients given 5f with fair adherence','Clients given 5f with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5f with fair adherence\n Clients given 5f with fair adherence\n \n 2023-08-17 11:31:51 UTC\n \n 2023-08-17 11:32:47 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2404\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5f \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4699)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 13:31:51',4,'2023-08-17 13:32:47',4,0,NULL,NULL,NULL,'250972a3-6fab-4d66-a028-7c43751cf95d'),(2405,'Clients given 6B with Undetectable Viral Load','Clients given 6B with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B with Undetectable Viral Load\n Clients given 6B with Undetectable Viral Load\n \n 2023-08-17 11:32:32 UTC\n \n 2023-08-17 11:33:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2405\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6B \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 13:32:32',4,'2023-08-17 13:33:32',4,0,NULL,NULL,NULL,'8a1f9b0e-f55d-40ed-b59f-92971f598921'),(2406,'Clients given 5f with good adherence','Clients given 5f with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5f with good adherence\n Clients given 5f with good adherence\n \n 2023-08-17 11:36:40 UTC\n \n 2023-08-17 11:37:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2406\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5f \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4699)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 13:36:40',4,'2023-08-17 13:37:11',4,0,NULL,NULL,NULL,'8839041b-b3d1-48b1-a0b2-bc09f91cad73'),(2407,'Clients given 6C with >=20 Copies Viral Load','Clients given 6C with >=20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with >=20 Copies Viral Load\n Clients given 6C with >=20 Copies Viral Load\n \n 2023-08-17 11:39:53 UTC\n \n 2023-08-17 11:40:55 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2407\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4702)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 13:39:53',4,'2023-08-17 13:40:55',4,0,NULL,NULL,NULL,'c44258e3-391b-4e79-87f6-c647692cb3a1'),(2408,'Clients given 5g with poor adherence','Clients given 5g with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5g with poor adherence\n Clients given 5g with poor adherence\n \n 2023-08-17 11:41:26 UTC\n \n 2023-08-17 11:41:56 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2408\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5g \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4700)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 13:41:26',4,'2023-08-17 13:41:56',4,0,NULL,NULL,NULL,'a21e3c23-e513-4a3f-b229-b0baad328af6'),(2409,'Clients given 6C with <20 Copies Viral Load','Clients given 6C with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with <20 Copies Viral Load\n Clients given 6C with <20 Copies Viral Load\n \n 2023-08-17 11:42:38 UTC\n \n 2023-08-17 11:43:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2409\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4702)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 13:42:38',4,'2023-08-17 13:43:20',4,0,NULL,NULL,NULL,'307392db-30aa-4e4c-a692-ab8350cb3f42'),(2410,'Clients given 5g with fair adherence','Clients given 5g with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5g with fair adherence\n Clients given 5g with fair adherence\n \n 2023-08-17 11:43:06 UTC\n \n 2023-08-17 11:43:28 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2410\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5g \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4700)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 13:43:06',4,'2023-08-17 13:43:28',4,0,NULL,NULL,NULL,'0875bc5c-9df9-43d6-8e7a-5363f19adc4f'),(2411,'Clients given 6C with Undetectable Viral Load','Clients given 6C with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with Undetectable Viral Load\n Clients given 6C with Undetectable Viral Load\n \n 2023-08-17 11:45:31 UTC\n \n 2023-08-17 11:46:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2411\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6C \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4702)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 13:45:31',4,'2023-08-17 13:46:32',4,0,NULL,NULL,NULL,'eb4392cf-c7f5-43c2-8f45-b56f46771ea3'),(2412,'Clients given 5g with good adherence','Clients given 5g with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5g with good adherence\n Clients given 5g with good adherence\n \n 2023-08-17 11:46:09 UTC\n \n 2023-08-17 11:46:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2412\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5g \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4700)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 13:46:09',4,'2023-08-17 13:46:30',4,0,NULL,NULL,NULL,'9878645d-2648-4c62-8679-1449355eaf0a'),(2413,'Clients given 5h with poor adherence','Clients given 5h with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5h with poor adherence\n Clients given 5h with poor adherence\n \n 2023-08-17 11:49:55 UTC\n \n 2023-08-17 11:51:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2413\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5h \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4701)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 13:49:55',4,'2023-08-17 13:51:43',4,0,NULL,NULL,NULL,'ad1e42cb-ff60-47fd-b8b1-0649da1899a1'),(2414,'Clients given 6D with >=20Copies Viral Load','Clients given 6D with >=20Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with >=20Copies Viral Load\n Clients given 6D with >=20Copies Viral Load\n \n 2023-08-17 11:50:35 UTC\n \n 2023-08-17 11:51:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2414\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4703)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 13:50:35',4,'2023-08-17 13:51:45',4,0,NULL,NULL,NULL,'dbcd7d71-ba25-4619-8d23-dd2592aaf59a'),(2415,'Clients given 6D with <20 Copies Viral Load','Clients given 6D with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with <20 Copies Viral Load\n Clients given 6D with <20 Copies Viral Load\n \n 2023-08-17 11:53:15 UTC\n \n 2023-08-17 11:54:09 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2415\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4703)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 13:53:15',4,'2023-08-17 13:54:09',4,0,NULL,NULL,NULL,'0199fd5f-2426-4c4e-b266-818a815ba80a'),(2416,'Clients given 5h with fair adherence','Clients given 5h with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5h with fair adherence\n Clients given 5h with fair adherence\n \n 2023-08-17 11:54:17 UTC\n \n 2023-08-17 11:54:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2416\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5h \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4701)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 13:54:17',4,'2023-08-17 13:54:39',4,0,NULL,NULL,NULL,'5478dbb5-4f3d-4a39-b263-625158d98129'),(2417,'Clients given 6D with Undetectable Viral Load','Clients given 6D with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with Undetectable Viral Load\n Clients given 6D with Undetectable Viral Load\n \n 2023-08-17 11:55:34 UTC\n \n 2023-08-17 11:56:31 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2417\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6D \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4703)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 13:55:34',4,'2023-08-17 13:56:31',4,0,NULL,NULL,NULL,'10a317c1-829c-4739-b7c0-f0b4ba18a69f'),(2418,'Clients given 5h with good adherence','Clients given 5h with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5h with good adherence\n Clients given 5h with good adherence\n \n 2023-08-17 11:57:56 UTC\n \n 2023-08-17 11:58:25 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2418\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5h \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4701)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 13:57:56',4,'2023-08-17 13:58:25',4,0,NULL,NULL,NULL,'00df085c-fd67-466a-94fa-2807a5cce6f7'),(2419,'Clients given 6E with >=20Copies Viral Load','Clients given 6E with >=20Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with >=20Copies Viral Load\n Clients given 6E with >=20Copies Viral Load\n \n 2023-08-17 12:02:11 UTC\n \n 2023-08-17 12:04:41 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2419\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4704)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 14:02:11',4,'2023-08-17 14:04:41',4,0,NULL,NULL,NULL,'7c9d1608-dd16-4a6f-a811-aa9c285da131'),(2420,'Clients given 6a with poor adherence','Clients given 6a with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6a with poor adherence\n Clients given 6a with poor adherence\n \n 2023-08-17 12:07:35 UTC\n \n 2023-08-17 12:07:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2420\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6a \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 14:07:35',4,'2023-08-17 14:07:53',4,0,NULL,NULL,NULL,'b1f7d697-7125-4ad4-b73d-8538c0d0bf37'),(2421,'Clients given 6E with <20 Copies Viral Load','Clients given 6E with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with <20 Copies Viral Load\n Clients given 6E with <20 Copies Viral Load\n \n 2023-08-17 12:07:43 UTC\n \n 2023-08-17 12:08:22 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2421\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4704)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 14:07:43',4,'2023-08-17 14:08:22',4,0,NULL,NULL,NULL,'76cdd1d3-9bb0-462b-a63d-5babfae535ae'),(2422,'Clients given 6a with fair adherence','Clients given 6a with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6a with fair adherence\n Clients given 6a with fair adherence\n \n 2023-08-17 12:09:05 UTC\n \n 2023-08-17 12:09:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2422\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6a \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 14:09:05',4,'2023-08-17 14:09:40',4,0,NULL,NULL,NULL,'7caf8270-2015-4b33-9cc4-2d23dcbbdd40'),(2423,'Clients given 6E with Undetectable Viral Load','Clients given 6E with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with Undetectable Viral Load\n Clients given 6E with Undetectable Viral Load\n \n 2023-08-17 12:09:16 UTC\n \n 2023-08-17 12:10:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2423\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6E \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4704)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 14:09:16',4,'2023-08-17 14:10:12',4,0,NULL,NULL,NULL,'42483bdd-5217-4e57-acfb-9dd6c405fc4e'),(2424,'Clients given 6a with good adherence','Clients given 6a with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6a with good adherence\n Clients given 6a with good adherence\n \n 2023-08-17 12:11:25 UTC\n \n 2023-08-17 12:11:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2424\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6a \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3686)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 14:11:25',4,'2023-08-17 14:11:53',4,0,NULL,NULL,NULL,'495d25ab-dea0-49b3-89de-2f64548597eb'),(2425,'Clients given 6F with >=20Copies Viral Load','Clients given 6F with >=20Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with >=20Copies Viral Load\n Clients given 6F with >=20Copies Viral Load\n \n 2023-08-17 12:12:26 UTC\n \n 2023-08-17 12:13:56 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2425\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4705)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- >=20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and oss.obs_datetime <= cast('2023-06-30'as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- >=20 Copies \n where o.concept_id = 4266 and o.value_coded = 4265 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) greaterThan20 \non Active_Patients.Id = greaterThan20.Id \n \n)) \n \n\n','2023-08-17 14:12:26',4,'2023-08-17 14:13:56',4,0,NULL,NULL,NULL,'72be7653-8e41-42f4-9a8d-caa979c15ef6'),(2426,'Clients given 6F with <20 Copies Viral Load','Clients given 6F with <20 Copies Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with <20 Copies Viral Load\n Clients given 6F with <20 Copies Viral Load\n \n 2023-08-17 12:14:54 UTC\n \n 2023-08-17 12:15:37 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2426\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4705)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- <20 Copies, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- <20 Copies \n where o.concept_id = 4266 and o.value_coded = 4264 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) lessThan20 \non Active_Patients.Id = lessThan20.Id \n \n)) \n \n\n','2023-08-17 14:14:54',4,'2023-08-17 14:15:37',4,0,NULL,NULL,NULL,'d11f84f3-e524-4688-9ad5-450362112a3d'),(2427,'Clients given 6b with poor adherence','Clients given 6b with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6b with poor adherence\n Clients given 6b with poor adherence\n \n 2023-08-17 12:15:12 UTC\n \n 2023-08-17 12:16:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2427\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6b \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 14:15:12',4,'2023-08-17 14:16:00',4,0,NULL,NULL,NULL,'c16525a3-70e2-41e5-948b-171525dbc0aa'),(2428,'Clients given 6F with Undetectable Viral Load','Clients given 6F with Undetectable Viral Load','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with Undetectable Viral Load\n Clients given 6F with Undetectable Viral Load\n \n 2023-08-17 12:16:55 UTC\n \n 2023-08-17 12:17:37 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2428\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6F \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4705)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n-- undetectable, Vira load results \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as observation_id \n from obs oss \n -- Viral load form \n where oss.concept_id = 4273 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n -- Undetectable \n where o.concept_id = 4266 and o.value_coded = 4263 \n and o.obs_datetime = max_observation \n group by o.person_id \n ) Undetectable \non Active_Patients.Id = Undetectable.Id \n \n)) \n \n\n','2023-08-17 14:16:55',4,'2023-08-17 14:17:37',4,0,NULL,NULL,NULL,'e278c929-0e08-4577-92f9-e1a972fcf688'),(2429,'Clients given 5a with >=20Copies Viral Load','Clients given 5a with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a with >=20Copies Viral Load\n Clients given 5a with >=20Copies Viral Load\n \n 2023-08-17 12:19:02 UTC\n \n 2023-08-17 12:21:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2429\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:19:02',4,'2023-08-17 14:21:57',4,0,NULL,NULL,NULL,'ac679df3-e5a4-4548-ba63-4fd778196ea4'),(2430,'Clients given 6b with fair adherence','Clients given 6b with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6b with fair adherence\n Clients given 6b with fair adherence\n \n 2023-08-17 12:19:38 UTC\n \n 2023-08-17 12:19:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2430\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6b \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 14:19:38',4,'2023-08-17 14:19:59',4,0,NULL,NULL,NULL,'c4aaf23a-6f87-424e-b8d6-b1519273b376'),(2431,'Clients given 6b with good adherence','Clients given 6b with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6b with good adherence\n Clients given 6b with good adherence\n \n 2023-08-17 12:21:00 UTC\n \n 2023-08-17 12:21:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2431\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6b \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 3687)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 14:21:00',4,'2023-08-17 14:21:45',4,0,NULL,NULL,NULL,'96917926-b178-4bf4-8113-7300329ee951'),(2432,'Clients given 5A with <20Copies Viral Load','Clients given 5A with <20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A with <20Copies Viral Load\n Clients given 5A with <20Copies Viral Load\n \n 2023-08-17 12:23:16 UTC\n \n 2023-08-17 12:25:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2432\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:23:16',4,'2023-08-17 14:25:32',4,0,NULL,NULL,NULL,'9a1038ff-dcfd-4b2c-93a9-d7c68030d1ef'),(2433,'Clients given 5A with Undetectable Viral Load','Clients given 5A with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5A with Undetectable Viral Load\n Clients given 5A with Undetectable Viral Load\n \n 2023-08-17 12:27:23 UTC\n \n 2023-08-17 12:28:22 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2433\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:27:23',4,'2023-08-17 14:28:22',4,0,NULL,NULL,NULL,'f401ae7b-f27f-4b25-926f-65e3b8c81863'),(2434,'Clients given 5B with >=20Copies Viral Load','Clients given 5B with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B with >=20Copies Viral Load\n Clients given 5B with >=20Copies Viral Load\n \n 2023-08-17 12:29:26 UTC\n \n 2023-08-17 12:33:25 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2434\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:29:26',4,'2023-08-17 14:33:25',4,0,NULL,NULL,NULL,'938a8cf8-cfb9-422e-be17-3a1e59e3c135'),(2435,'Clients given 6c with poor adherence','Clients given 6c with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6c with poor adherence\n Clients given 6c with poor adherence\n \n 2023-08-17 12:34:23 UTC\n \n 2023-08-17 12:35:25 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2435\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6c \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4702)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 14:34:23',4,'2023-08-17 14:35:25',4,0,NULL,NULL,NULL,'a854add1-66a5-4624-94b8-ee9cc9f6b618'),(2436,'Clients given 5B with <20 Copies Viral Load','','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B with <20 Copies Viral Load\n \n \n 2023-08-17 12:34:37 UTC\n \n 2023-08-17 12:35:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2436\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:34:37',4,'2023-08-17 14:35:36',4,0,NULL,NULL,NULL,'160dcddc-c186-4d31-a0c8-47edca4fc581'),(2437,'Clients given 5B with Undetectable Viral Load','Clients given 5B with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5B with Undetectable Viral Load\n Clients given 5B with Undetectable Viral Load\n \n 2023-08-17 12:36:46 UTC\n \n 2023-08-17 12:38:09 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2437\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:36:46',4,'2023-08-17 14:38:09',4,0,NULL,NULL,NULL,'5f976c00-44ef-4b36-bed0-b976bb7f2b55'),(2438,'Clients given 6c with fair adherence','Clients given 6c with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6c with fair adherence\n Clients given 6c with fair adherence\n \n 2023-08-17 12:36:48 UTC\n \n 2023-08-17 12:37:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2438\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6c \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4702)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 14:36:48',4,'2023-08-17 14:37:12',4,0,NULL,NULL,NULL,'65b4eb44-cc9f-494e-b621-ee1bdedbc549'),(2439,'Clients given 6c with good adherence','Clients given 6c with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6c with good adherence\n Clients given 6c with good adherence\n \n 2023-08-17 12:38:40 UTC\n \n 2023-08-17 12:38:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2439\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6c \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4702)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 14:38:40',4,'2023-08-17 14:38:57',4,0,NULL,NULL,NULL,'17b46231-8af2-49d6-ab43-17a6d13d30d4'),(2440,'Clients given 5C with >=20 Copies Viral Load','Clients given 5C with >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C with >=20 Copies Viral Load\n Clients given 5C with >=20 Copies Viral Load\n \n 2023-08-17 12:38:53 UTC\n \n 2023-08-17 12:39:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2440\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:38:53',4,'2023-08-17 14:39:46',4,0,NULL,NULL,NULL,'ddd536bc-c879-4847-9c50-cc79a002813e'),(2441,'Clients given 6d with poor adherence','Clients given 6d with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d with poor adherence\n Clients given 6d with poor adherence\n \n 2023-08-17 12:40:45 UTC\n \n 2023-08-17 12:41:01 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2441\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4703)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 14:40:45',4,'2023-08-17 14:41:01',4,0,NULL,NULL,NULL,'fa914aa2-ce96-4063-a749-7718cf76a361'),(2442,'Clients given 5C with <20 Copies Viral Load','Clients given 5C with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C with <20 Copies Viral Load\n Clients given 5C with <20 Copies Viral Load\n \n 2023-08-17 12:41:03 UTC\n \n 2023-08-17 12:43:01 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2442\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:41:03',4,'2023-08-17 14:43:01',4,0,NULL,NULL,NULL,'394324e6-b5b5-406f-9fb0-83194dc1b533'),(2443,'Clients given 6d with fair adherence','Clients given 6d with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d with fair adherence\n Clients given 6d with fair adherence\n \n 2023-08-17 12:41:48 UTC\n \n 2023-08-17 12:42:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2443\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4703)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 14:41:48',4,'2023-08-17 14:42:15',4,0,NULL,NULL,NULL,'6a150299-a792-4070-953d-c475224522f9'),(2444,' Clients given 6d with good adherence',' Clients given 6d with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d with good adherence\n Clients given 6d with good adherence\n \n 2023-08-17 12:43:47 UTC\n \n 2023-08-17 12:44:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2444\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4703)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 14:43:47',4,'2023-08-17 14:44:08',4,0,NULL,NULL,NULL,'66ddc4ec-de69-43a5-8cda-3e7f9f8d28af'),(2445,'Clients given 5C with Undetectable Viral Load','Clients given 5C with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5C with Undetectable Viral Load\n Clients given 5C with Undetectable Viral Load\n \n 2023-08-17 12:44:54 UTC\n \n 2023-08-17 12:50:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2445\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 14:44:54',4,'2023-08-17 14:50:20',4,0,NULL,NULL,NULL,'c75e1385-b87e-49d1-a8ba-418f96c68379'),(2446,'Clients given 6e with poor adherence','Clients given 6e with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with poor adherence\n Clients given 6e with poor adherence\n \n 2023-08-17 12:49:27 UTC\n \n 2023-08-17 12:49:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2446\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6e \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4704)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 14:49:27',4,'2023-08-17 14:49:43',4,0,NULL,NULL,NULL,'0a65b09f-f0a6-45a6-a240-46f0a48dda2a'),(2447,'Clients given 6e with fair adherence','Clients given 6e with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with fair adherence\n Clients given 6e with fair adherence\n \n 2023-08-17 12:50:30 UTC\n \n 2023-08-17 12:50:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2447\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6e \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4704)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 14:50:30',4,'2023-08-17 14:50:58',4,0,NULL,NULL,NULL,'3e2fec32-323e-453b-b4e1-23e746f37f1a'),(2448,'Clients given 6e with good adherence','Clients given 6e with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with good adherence\n Clients given 6e with good adherence\n \n 2023-08-17 12:52:12 UTC\n \n 2023-08-17 12:53:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2448\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6e \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4704)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 14:52:12',4,'2023-08-17 14:53:46',4,0,NULL,NULL,NULL,'ca2d72c9-cfb8-44bd-8859-2813817d6a80'),(2449,'Clients given 6f with poor adherence','Clients given 6f with poor adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with poor adherence\n Clients given 6f with poor adherence\n \n 2023-08-17 12:55:45 UTC\n \n 2023-08-17 12:56:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2449\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6f \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4705)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 3702 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 3702 \n and o.obs_datetime = max_observation \n ) poor_adherence \non Active_Patients.Id = poor_adherence.Id \n)) \n \n\n','2023-08-17 14:55:45',4,'2023-08-17 14:56:07',4,0,NULL,NULL,NULL,'68e19030-f17c-4489-8e26-e854ac11fcde'),(2450,'Clients given 6f with fair adherence','Clients given 6f with fair adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with fair adherence\n Clients given 6f with fair adherence\n \n 2023-08-17 12:56:59 UTC\n \n 2023-08-17 12:57:27 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2450\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6f \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4705)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2306 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2306 \n and o.obs_datetime = max_observation \n ) fair_adherence \non Active_Patients.Id = fair_adherence.Id \n)) \n \n\n','2023-08-17 14:56:59',4,'2023-08-17 14:57:27',4,0,NULL,NULL,NULL,'9680051f-31ff-417c-9560-8bfce8b63699'),(2451,'Clients given 6f with good adherence','Clients given 6f with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with good adherence\n Clients given 6f with good adherence\n \n 2023-08-17 12:57:57 UTC\n \n 2023-08-17 12:58:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2451\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6f \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4705)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 14:57:57',4,'2023-08-17 14:58:15',4,0,NULL,NULL,NULL,'44fef653-ab93-4af5-a5b4-84c2dc981aee'),(2452,'Clients given 5D with >=20Copies_Viral_Load','Clients given 5D with >=20Copies_Viral_Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D with >=20Copies_Viral_Load\n Clients given 5D with >=20Copies_Viral_Load\n \n 2023-08-17 13:57:36 UTC\n \n 2023-08-17 14:00:01 UTC\n \n \n endDate\n \n java.util.Date\n true\n \n \n startDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2452\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 15:57:36',4,'2023-08-17 16:00:01',4,0,NULL,NULL,NULL,'bcaf7abb-e0b1-4b0d-8bce-72a0bcd6aa19'),(2453,'Clients given 5a with poor adherence','Clients given 5a with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a with poor adherence\n Clients given 5a with poor adherence\n \n 2023-08-17 13:57:52 UTC\n \n 2023-08-17 13:59:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2453\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 15:57:52',4,'2023-08-17 15:59:50',4,0,NULL,NULL,NULL,'a744dde1-e30e-4a5c-877e-a5ad781ff393'),(2454,'Clients given 5a with fair adherence','Clients given 5a with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a with fair adherence\n Clients given 5a with fair adherence\n \n 2023-08-17 14:01:28 UTC\n \n 2023-08-17 14:02:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2454\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:01:28',4,'2023-08-17 16:02:53',4,0,NULL,NULL,NULL,'63a61c4d-d9b0-4d4b-91a9-9aeba57141aa'),(2455,'Clients given 5D with <20Copies_Viral_Load','Clients given 5D with <20Copies_Viral_Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D with <20Copies_Viral_Load\n Clients given 5D with <20Copies_Viral_Load\n \n 2023-08-17 14:01:35 UTC\n \n 2023-08-17 14:02:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2455\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:01:35',4,'2023-08-17 16:02:39',4,0,NULL,NULL,NULL,'ec730cde-9848-44d6-93c0-081b9faf2710'),(2456,'Clients given 5D with Undetectable Viral Load','Clients given 5D with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5D with Undetectable Viral Load\n Clients given 5D with Undetectable Viral Load\n \n 2023-08-17 14:03:49 UTC\n \n 2023-08-17 14:05:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2456\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:03:49',4,'2023-08-17 16:05:14',4,0,NULL,NULL,NULL,'f254459b-e8e8-4930-837c-a1c156604ebf'),(2457,'Clients given 5E with >=20Copies_Viral_Load','Clients given 5E with >=20Copies_Viral_Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E with >=20Copies_Viral_Load\n Clients given 5E with >=20Copies_Viral_Load\n \n 2023-08-17 14:05:53 UTC\n \n 2023-08-17 14:06:48 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2457\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:05:53',4,'2023-08-17 16:06:48',4,0,NULL,NULL,NULL,'4bea5c18-e6c1-4c17-b1d2-df2a72d826b4'),(2458,'Clients given 5a with good adherence','Clients given 5a with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5a with good adherence\n Clients given 5a with good adherence\n \n 2023-08-17 14:06:18 UTC\n \n 2023-08-17 14:07:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2458\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:06:18',4,'2023-08-17 16:07:21',4,0,NULL,NULL,NULL,'6b4360ec-6413-487c-b5ce-6306a93d594d'),(2459,'Clients given 5E with <20 Copies Viral Load','Clients given 5E with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E with <20 Copies Viral Load\n Clients given 5E with <20 Copies Viral Load\n \n 2023-08-17 14:07:29 UTC\n \n 2023-08-17 14:08:34 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2459\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:07:29',4,'2023-08-17 16:08:34',4,0,NULL,NULL,NULL,'2941db2b-ab51-4716-85b7-d433faab7089'),(2460,'Clients given 5b with poor adherence','Clients given 5b with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5b with poor adherence\n Clients given 5b with poor adherence\n \n 2023-08-17 14:08:02 UTC\n \n 2023-08-17 14:08:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2460\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:08:02',4,'2023-08-17 16:08:58',4,0,NULL,NULL,NULL,'40f47ac2-87c8-4b1c-a673-ce43a9e640ae'),(2461,'Clients given 5E with Undetectable Viral Load','Clients given 5E with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5E with Undetectable Viral Load\n Clients given 5E with Undetectable Viral Load\n \n 2023-08-17 14:09:17 UTC\n \n 2023-08-17 14:10:49 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2461\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:09:17',4,'2023-08-17 16:10:49',4,0,NULL,NULL,NULL,'4bff5bff-95d4-4b93-b4e0-bb6a0c0e70b9'),(2462,'Clients given 5b with fair adherence','Clients given 5b with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5b with fair adherence\n Clients given 5b with fair adherence\n \n 2023-08-17 14:09:25 UTC\n \n 2023-08-17 14:10:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2462\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:09:25',4,'2023-08-17 16:10:18',4,0,NULL,NULL,NULL,'6fc3a2a5-a532-4394-8c1f-a824d12535b1'),(2463,'Clients given 5b with good adherence','Clients given 5b with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5b with good adherence\n Clients given 5b with good adherence\n \n 2023-08-17 14:11:16 UTC\n \n 2023-08-17 14:15:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2463\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:11:16',4,'2023-08-17 16:15:00',4,0,NULL,NULL,NULL,'0370fb97-e838-423b-a27f-84b8bfccbdf7'),(2464,'Clients given 5F with >=20Copies Viral Load','Clients given 5F with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F with >=20Copies Viral Load\n Clients given 5F with >=20Copies Viral Load\n \n 2023-08-17 14:11:27 UTC\n \n 2023-08-17 14:12:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2464\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:11:27',4,'2023-08-17 16:12:29',4,0,NULL,NULL,NULL,'57bdd154-b1fd-445e-9c4f-4c86d9574dca'),(2465,'Clients given 5c with poor adherence','Clients given 5c with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5c with poor adherence\n Clients given 5c with poor adherence\n \n 2023-08-17 14:11:45 UTC\n \n 2023-08-17 14:15:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2465\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:11:45',4,'2023-08-17 16:15:44',4,0,NULL,NULL,NULL,'55fe3a12-7f92-4c13-a9e4-130999a508ab'),(2466,'Clients given 5F with <20 Copies Viral Load','Clients given 5F with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F with <20 Copies Viral Load\n Clients given 5F with <20 Copies Viral Load\n \n 2023-08-17 14:13:17 UTC\n \n 2023-08-17 14:14:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2466\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:13:17',4,'2023-08-17 16:14:26',4,0,NULL,NULL,NULL,'99587c4e-7a32-4f0a-8875-db1f5ded867f'),(2467,'Clients given 5F with Undetectable Viral Load','Clients given 5F with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5F with Undetectable Viral Load\n Clients given 5F with Undetectable Viral Load\n \n 2023-08-17 14:15:33 UTC\n \n 2023-08-17 14:16:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2467\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:15:33',4,'2023-08-17 16:16:40',4,0,NULL,NULL,NULL,'ab5801be-bc9d-4d49-b637-c40c1442e859'),(2468,'Clients given 5c with fair adherence','Clients given 5c with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5c with fair adherence\n Clients given 5c with fair adherence\n \n 2023-08-17 14:16:13 UTC\n \n 2023-08-17 14:17:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2468\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:16:13',4,'2023-08-17 16:17:42',4,0,NULL,NULL,NULL,'c3f8c51c-b012-4725-93b5-3806093e90a2'),(2469,'Clients given 5G with >=20Copies Viral Load','Clients given 5G with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G with >=20Copies Viral Load\n Clients given 5G with >=20Copies Viral Load\n \n 2023-08-17 14:17:34 UTC\n \n 2023-08-17 14:19:13 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2469\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:17:34',4,'2023-08-17 16:19:13',4,0,NULL,NULL,NULL,'ac5ef4a7-17ea-4550-bd66-73b5d95c9c04'),(2470,'Clients given 5c with good adherence','Clients given 5c with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5c with good adherence\n Clients given 5c with good adherence\n \n 2023-08-17 14:18:32 UTC\n \n 2023-08-17 14:22:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2470\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:18:32',4,'2023-08-17 16:22:06',4,0,NULL,NULL,NULL,'c667f290-2936-42fb-859e-4d8978b03814'),(2471,'Clients given 5d with poor adherence','Clients given 5d with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5d with poor adherence\n Clients given 5d with poor adherence\n \n 2023-08-17 14:19:32 UTC\n \n 2023-08-17 14:24:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2471\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:19:32',4,'2023-08-17 16:24:53',4,0,NULL,NULL,NULL,'4f154124-3ed5-4605-afb8-ab6d47c97cfa'),(2472,'Clients given 5G with <20 Copies Viral Load','Clients given 5G with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G with <20 Copies Viral Load\n Clients given 5G with <20 Copies Viral Load\n \n 2023-08-17 14:20:08 UTC\n \n 2023-08-17 14:23:09 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2472\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:20:08',4,'2023-08-17 16:23:09',4,0,NULL,NULL,NULL,'1b6b36fd-ab78-457d-9af4-ecd3ec235533'),(2473,'Clients given 5G with Undetectable Viral Load','Clients given 5G with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5G with Undetectable Viral Load\n Clients given 5G with Undetectable Viral Load\n \n 2023-08-17 14:24:11 UTC\n \n 2023-08-17 14:25:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2473\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:24:11',4,'2023-08-17 16:25:46',4,0,NULL,NULL,NULL,'8e1a22eb-ac03-450c-9550-43957fc8e8af'),(2474,'Clients given 5d with fair adherence','Clients given 5d with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5d with fair adherence\n Clients given 5d with fair adherence\n \n 2023-08-17 14:26:28 UTC\n \n 2023-08-17 14:27:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2474\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:26:28',4,'2023-08-17 16:27:32',4,0,NULL,NULL,NULL,'64f11aa4-8642-4293-8a6d-ed4436c8b783'),(2475,'Clients given 5H with >=20Copies Viral Load','Clients given 5H with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H with >=20Copies Viral Load\n Clients given 5H with >=20Copies Viral Load\n \n 2023-08-17 14:26:40 UTC\n \n 2023-08-17 14:27:31 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2475\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:26:40',4,'2023-08-17 16:27:31',4,0,NULL,NULL,NULL,'3184b05c-dbf5-4c1a-abed-d310e409fb09'),(2476,'Clients given 5d with good adherence','Clients given 5d with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5d with good adherence\n Clients given 5d with good adherence\n \n 2023-08-17 14:27:55 UTC\n \n 2023-08-17 14:35:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2476\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:27:55',4,'2023-08-17 16:35:53',4,0,NULL,NULL,NULL,'d60ecbe6-5a56-449d-814e-d669d864ed86'),(2477,'Clients given 5H with <20 Copies Viral Load','Clients given 5H with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H with <20 Copies Viral Load\n Clients given 5H with <20 Copies Viral Load\n \n 2023-08-17 14:28:41 UTC\n \n 2023-08-17 14:30:28 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2477\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:28:41',4,'2023-08-17 16:30:28',4,0,NULL,NULL,NULL,'54488b0e-09b6-4801-8d42-510fefdfa04c'),(2478,'Clients given 5H with Undetectable Viral Load','Clients given 5H with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5H with Undetectable Viral Load\n Clients given 5H with Undetectable Viral Load\n \n 2023-08-17 14:31:09 UTC\n \n 2023-08-17 14:34:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2478\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:31:09',4,'2023-08-17 16:34:51',4,0,NULL,NULL,NULL,'7a4e4111-651c-407d-b445-041fd397599c'),(2479,'Clients given 5d with good adherence','Clients given 5d with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5d with good adherence\n Clients given 5d with good adherence\n \n 2023-08-17 14:33:34 UTC\n \n 2023-08-17 14:33:55 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2479\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 5d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4697)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 16:33:34',4,'2023-08-17 16:33:55',4,0,NULL,NULL,NULL,'3300f25b-40f1-4c24-8223-41cfada5c62a'),(2480,'Clients given 6A with >=20Copies Viral Load','Clients given 6A with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A with >=20Copies Viral Load\n Clients given 6A with >=20Copies Viral Load\n \n 2023-08-17 14:35:48 UTC\n \n 2023-08-17 14:36:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2480\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:35:48',4,'2023-08-17 16:36:40',4,0,NULL,NULL,NULL,'aaaf1254-b937-4fdd-abdf-7f99bc97c9e4'),(2481,'Clients given 5e with poor adherence','Clients given 5e with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5e with poor adherence\n Clients given 5e with poor adherence\n \n 2023-08-17 14:36:47 UTC\n \n 2023-08-17 14:37:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2481\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:36:47',4,'2023-08-17 16:37:52',4,0,NULL,NULL,NULL,'b6365db8-5402-488e-bf43-1b4b3869592c'),(2482,'Clients given 6A with <20 Copies Viral Load','Clients given 6A with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A with <20 Copies Viral Load\n Clients given 6A with <20 Copies Viral Load\n \n 2023-08-17 14:37:57 UTC\n \n 2023-08-17 14:40:25 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2482\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:37:57',4,'2023-08-17 16:40:25',4,0,NULL,NULL,NULL,'6dc49bb6-9be8-4b6b-9db7-7cd1e9e9832b'),(2483,'Clients given 5e with fair adherence','Clients given 5e with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5e with fair adherence\n Clients given 5e with fair adherence\n \n 2023-08-17 14:38:45 UTC\n \n 2023-08-17 14:40:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2483\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:38:45',4,'2023-08-17 16:40:42',4,0,NULL,NULL,NULL,'c9761b31-3a7f-4cdb-bce2-e422d0f0a1d9'),(2484,'Clients given 6A with Undetectable Viral Load','Clients given 6A with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6A with Undetectable Viral Load\n Clients given 6A with Undetectable Viral Load\n \n 2023-08-17 14:41:52 UTC\n \n 2023-08-17 14:43:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2484\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:41:52',4,'2023-08-17 16:43:11',4,0,NULL,NULL,NULL,'88ff8b16-c2f3-4f73-accf-0b799dbd4357'),(2485,'Clients given 6B with >=20Copies Viral Load','Clients given 6B with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B with >=20Copies Viral Load\n Clients given 6B with >=20Copies Viral Load\n \n 2023-08-17 14:43:49 UTC\n \n 2023-08-17 15:26:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2485\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:43:49',4,'2023-08-17 17:26:07',4,0,NULL,NULL,NULL,'3e4ca350-0d23-4326-b54b-1da860205aa2'),(2486,'Clients given 5e with good adherence','Clients given 5e with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5e with good adherence\n Clients given 5e with good adherence\n \n 2023-08-17 14:44:26 UTC\n \n 2023-08-17 14:46:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2486\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:44:26',4,'2023-08-17 16:46:50',4,0,NULL,NULL,NULL,'bf269091-cd68-4987-adc0-88a0d53b0799'),(2487,'Clients given 5f with poor adherence','Clients given 5f with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5f with poor adherence\n Clients given 5f with poor adherence\n \n 2023-08-17 14:45:30 UTC\n \n 2023-08-17 14:47:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2487\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:45:30',4,'2023-08-17 16:47:18',4,0,NULL,NULL,NULL,'8628ac34-e4de-44ad-bf49-0cd48799c0e0'),(2488,'Clients given 5f with fair adherence','Clients given 5f with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5f with fair adherence\n Clients given 5f with fair adherence\n \n 2023-08-17 14:47:44 UTC\n \n 2023-08-17 14:48:56 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2488\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:47:44',4,'2023-08-17 16:48:56',4,0,NULL,NULL,NULL,'05773449-f7c2-428e-b2d7-13d526846f6d'),(2489,'Clients given 5f with good adherence','Clients given 5f with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5f with good adherence\n Clients given 5f with good adherence\n \n 2023-08-17 14:48:23 UTC\n \n 2023-08-17 14:51:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2489\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:48:23',4,'2023-08-17 16:51:06',4,0,NULL,NULL,NULL,'0a2c5054-fcf0-46e8-94bd-150cc697fad7'),(2490,'Clients given 5g with poor adherence','Clients given 5g with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5g with poor adherence\n Clients given 5g with poor adherence\n \n 2023-08-17 14:51:41 UTC\n \n 2023-08-17 14:52:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2490\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:51:41',4,'2023-08-17 16:52:53',4,0,NULL,NULL,NULL,'92f0cb76-2f6b-4be0-b525-90c4d4665b90'),(2491,'Clients given 5g with fair adherence','Clients given 5g with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5g with fair adherence\n Clients given 5g with fair adherence\n \n 2023-08-17 14:54:10 UTC\n \n 2023-08-17 14:55:17 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2491\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:54:10',4,'2023-08-17 16:55:17',4,0,NULL,NULL,NULL,'d159ee3c-798c-4b94-ae55-f17634b6bd38'),(2492,'Clients given 5g with good adherence','Clients given 5g with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5g with good adherence\n Clients given 5g with good adherence\n \n 2023-08-17 14:55:50 UTC\n \n 2023-08-17 14:56:54 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2492\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:55:50',4,'2023-08-17 16:56:54',4,0,NULL,NULL,NULL,'2c0bc567-51cc-4892-a4ce-5266c8e9cf58'),(2493,'Clients given 5h with poor adherence','Clients given 5h with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5h with poor adherence\n Clients given 5h with poor adherence\n \n 2023-08-17 14:56:39 UTC\n \n 2023-08-17 14:58:17 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2493\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:56:39',4,'2023-08-17 16:58:17',4,0,NULL,NULL,NULL,'18332615-0cd2-4f3c-a2dd-537056310823'),(2494,'Clients given 5h with fair adherence','Clients given 5h with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5h with fair adherence\n Clients given 5h with fair adherence\n \n 2023-08-17 14:57:51 UTC\n \n 2023-08-17 14:59:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2494\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:57:51',4,'2023-08-17 16:59:12',4,0,NULL,NULL,NULL,'9bee8b12-d34c-4ec0-a136-cdc38d312f76'),(2495,'Clients given 5h with good adherence','Clients given 5h with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 5h with good adherence\n Clients given 5h with good adherence\n \n 2023-08-17 14:59:01 UTC\n \n 2023-08-17 15:00:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2495\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 16:59:01',4,'2023-08-17 17:00:11',4,0,NULL,NULL,NULL,'8d2837ca-19e0-461e-8bde-fdee3e9f117c'),(2496,'Clients given 6a with poor adherence','Clients given 6a with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6a with poor adherence\n Clients given 6a with poor adherence\n \n 2023-08-17 15:00:41 UTC\n \n 2023-08-17 15:01:40 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2496\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:00:41',4,'2023-08-17 17:01:40',4,0,NULL,NULL,NULL,'25323965-1cc3-4c63-b997-5c6ff173ad1b'),(2497,'Clients given 6a with fair adherence','Clients given 6a with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6a with fair adherence\n Clients given 6a with fair adherence\n \n 2023-08-17 15:01:29 UTC\n \n 2023-08-17 15:03:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2497\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:01:29',4,'2023-08-17 17:03:14',4,0,NULL,NULL,NULL,'38990f18-eb9c-43ff-8323-96c3a6eb90c2'),(2498,'Clients given 6a with good adherence','Clients given 6a with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6a with good adherence\n Clients given 6a with good adherence\n \n 2023-08-17 15:02:51 UTC\n \n 2023-08-17 15:04:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2498\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:02:51',4,'2023-08-17 17:04:00',4,0,NULL,NULL,NULL,'2e00abe1-aed1-485e-858f-2a0baf0eaf3c'),(2499,'Clients given 6b with poor adherence','Clients given 6b with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6b with poor adherence\n Clients given 6b with poor adherence\n \n 2023-08-17 15:04:48 UTC\n \n 2023-08-17 15:06:13 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2499\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:04:48',4,'2023-08-17 17:06:13',4,0,NULL,NULL,NULL,'2452d808-0319-435c-8a68-0f849c38d53e'),(2500,'Clients given 6b with fair adherence','Clients given 6b with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6b with fair adherence\n Clients given 6b with fair adherence\n \n 2023-08-17 15:06:01 UTC\n \n 2023-08-17 15:08:42 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2500\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:06:01',4,'2023-08-17 17:08:42',4,0,NULL,NULL,NULL,'6a9e9b7e-3e06-4f47-9abb-ad685a5d86ca'),(2501,'Clients given 6b with good adherence','Clients given 6b with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6b with good adherence\n Clients given 6b with good adherence\n \n 2023-08-17 15:06:55 UTC\n \n 2023-08-17 15:09:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2501\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:06:55',4,'2023-08-17 17:09:06',4,0,NULL,NULL,NULL,'8340a9bc-f2fc-4a2d-ab84-74569dfe8a86'),(2502,'Clients given 6c with poor adherence','Clients given 6c with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6c with poor adherence\n Clients given 6c with poor adherence\n \n 2023-08-17 15:09:40 UTC\n \n 2023-08-17 15:11:01 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2502\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:09:40',4,'2023-08-17 17:11:01',4,0,NULL,NULL,NULL,'052f51db-d6e4-4078-9f3f-bed7d17b48bd'),(2503,'Clients given 6c with fair adherence','Clients given 6c with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6c with fair adherence\n Clients given 6c with fair adherence\n \n 2023-08-17 15:10:40 UTC\n \n 2023-08-17 15:12:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2503\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:10:40',4,'2023-08-17 17:12:06',4,0,NULL,NULL,NULL,'f8e62785-7303-493a-9c20-6c9f4280faf0'),(2504,'Clients given 6c with good adherence','Clients given 6c with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6c with good adherence\n Clients given 6c with good adherence\n \n 2023-08-17 15:11:54 UTC\n \n 2023-08-17 15:13:48 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2504\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:11:54',4,'2023-08-17 17:13:48',4,0,NULL,NULL,NULL,'9b361e36-e897-4212-8c7f-26121e595425'),(2505,'Clients given 6d with poor adherence','Clients given 6d with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d with poor adherence\n Clients given 6d with poor adherence\n \n 2023-08-17 15:13:21 UTC\n \n 2023-08-17 15:15:04 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2505\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:13:21',4,'2023-08-17 17:15:04',4,0,NULL,NULL,NULL,'56b2509b-811c-4452-8432-5807792f207a'),(2506,'Clients given 6d with fair adherence','Clients given 6d with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d with fair adherence\n Clients given 6d with fair adherence\n \n 2023-08-17 15:14:20 UTC\n \n 2023-08-17 15:16:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2506\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:14:20',4,'2023-08-17 17:16:21',4,0,NULL,NULL,NULL,'2808446d-305f-4bf7-b83b-3a5aad7cc119'),(2507,'Clients given 6d with good adherence','Clients given 6d with good adherence','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d with good adherence\n Clients given 6d with good adherence\n \n 2023-08-17 15:17:32 UTC\n \n 2023-08-17 15:17:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2507\n \nselect distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id = :location or parent_location = :location) \nand o.person_id in \n(SELECT distinct Active_Patients.Id \nFROM \n(( \n -- 6d \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age \n \n from obs o \n -- Picking Followup Date from Latest Followup Form \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n AND o.person_id in ( \n \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND CAST(os.value_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(os.value_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where CAST(death_date AS DATE) <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select person_id \n FROM \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 5416 \n and value_coded = 1 and voided = 0 \n and cast(obs_datetime as date) <= cast(:endDate as date) \n and voided = 0 \n group by person_id)visitor \n \n ) \n ) \n \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n having Age < 15 \n ) AS Seen_Previous_ART_Clients \n) \n \n)Active_Patients \n \nINNER JOIN \n \n(SELECT regimen.Id as Id \nFROM \n( SELECT currentreg.person_id as Id,COALESCE(switch_regimen,substitute_regimen,current_regimen) ARV_regimen \n FROM( \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS current_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2250 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as currentreg \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS substitute_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 4284 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as substitutereg \n ON substitutereg.person_id = currentreg.person_id \n \n LEFT OUTER JOIN \n \n \n (select distinct o.person_id, max(o.obs_datetime) as maxdate, SUBSTRING(MAX(CONCAT(o.obs_datetime, o.value_coded)), 20) AS switch_regimen \n from obs o \n INNER JOIN patient_identifier ON patient_identifier.patient_id = o.person_id AND patient_identifier.preferred=1 \n where o.concept_id = 2268 \n AND o.voided = 0 \n and o.obs_datetime <= cast(:endDate as date) \n group by person_id) as switchreg \n ON switchreg.person_id = currentreg.person_id \n ) \n \n )as regimen \n where regimen.ARV_regimen = 4703)Current_Reg \nON Active_Patients.Id = Current_Reg.Id \n \nINNER JOIN \n \n-- Adherence \n ( \n select o.person_id as Id, o.value_coded \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as adherence_hiv \n from obs oss \n where oss.concept_id = 2308 and oss.value_coded = 2305 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 2308 and o.value_coded = 2305 \n and o.obs_datetime = max_observation \n ) good_adherence \non Active_Patients.Id = good_adherence.Id \n)) \n \n\n','2023-08-17 17:17:32',4,'2023-08-17 17:17:52',4,0,NULL,NULL,NULL,'a10f7cfb-6012-4c2a-8f4f-f9ef7cdd8310'),(2508,'Clients given 6d with good adherence','Clients given 6d with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6d with good adherence\n Clients given 6d with good adherence\n \n 2023-08-17 15:18:32 UTC\n \n 2023-08-17 15:19:41 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2508\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:18:32',4,'2023-08-17 17:19:41',4,0,NULL,NULL,NULL,'e271c92e-f3e8-4218-a758-f2d91fd4173e'); -INSERT INTO `serialized_object` VALUES (2509,'Clients given 6e with poor adherence','Clients given 6e with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with poor adherence\n Clients given 6e with poor adherence\n \n 2023-08-17 15:19:01 UTC\n \n 2023-08-17 15:20:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2509\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:19:01',4,'2023-08-17 17:20:53',4,0,NULL,NULL,NULL,'8c2c0191-d6e6-4f9c-a84d-976f24a47e5a'),(2510,'Clients given 6e with fair adherence','Clients given 6e with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with fair adherence\n Clients given 6e with fair adherence\n \n 2023-08-17 15:20:17 UTC\n \n 2023-08-17 15:22:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2510\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:20:17',4,'2023-08-17 17:22:00',4,0,NULL,NULL,NULL,'16552ea9-b4bb-4ae3-ae13-c04d366a5a72'),(2511,'Clients given 6e with good adherence','Clients given 6e with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with good adherence\n Clients given 6e with good adherence\n \n 2023-08-17 15:21:28 UTC\n \n 2023-08-17 15:23:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2511\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:21:28',4,'2023-08-17 17:23:08',4,0,NULL,NULL,NULL,'ca215c1b-6a15-42a3-b752-9ce21c651e13'),(2512,'Clients given 6f with poor adherence','Clients given 6f with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with poor adherence\n Clients given 6f with poor adherence\n \n 2023-08-17 15:22:56 UTC\n \n 2023-08-17 15:24:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2512\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:22:56',4,'2023-08-17 17:24:10',4,0,NULL,NULL,NULL,'ba0a85d0-9c18-49b9-8c42-417c8d96221c'),(2513,'Clients given 6f with fair adherence','Clients given 6f with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with fair adherence\n Clients given 6f with fair adherence\n \n 2023-08-17 15:23:41 UTC\n \n 2023-08-17 15:25:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2513\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:23:41',4,'2023-08-17 17:25:35',4,0,NULL,NULL,NULL,'7abe4ec4-ba33-4f66-97c3-33ffd356c478'),(2514,'Clients given 6f with good adherence','Clients given 6f with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with good adherence\n Clients given 6f with good adherence\n \n 2023-08-17 15:25:08 UTC\n \n 2023-08-17 15:27:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2514\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:25:08',4,'2023-08-17 17:27:07',4,0,NULL,NULL,NULL,'605e06e0-b274-46a5-8404-e45f6bdbf36d'),(2515,'Clients given 6B with <20 Copies Viral Load','Clients given 6B with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B with <20 Copies Viral Load\n Clients given 6B with <20 Copies Viral Load\n \n 2023-08-17 16:05:27 UTC\n \n 2023-08-17 16:06:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2515\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:05:27',4,'2023-08-17 18:06:26',4,0,NULL,NULL,NULL,'57a592d4-f5a1-4ac8-afd9-dbabd8335120'),(2516,'Clients given 6B with Undetectable Viral Load','Clients given 6B with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B with Undetectable Viral Load\n Clients given 6B with Undetectable Viral Load\n \n 2023-08-17 16:07:16 UTC\n \n 2023-08-17 17:13:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2516\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:07:16',4,'2023-08-17 19:13:12',4,0,NULL,NULL,NULL,'9a6c692c-675e-490a-827d-788308c41aa2'),(2517,'Clients given 6C with >=20 Copies Viral Load','Clients given 6C with >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with >=20 Copies Viral Load\n Clients given 6C with >=20 Copies Viral Load\n \n 2023-08-17 16:09:20 UTC\n \n 2023-08-17 16:10:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2517\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:09:20',4,'2023-08-17 18:10:11',4,0,NULL,NULL,NULL,'2b0f18d1-d6bc-48db-81e9-139e7127a014'),(2518,'Clients given 6C with <20 Copies Viral Load','Clients given 6C with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with <20 Copies Viral Load\n Clients given 6C with <20 Copies Viral Load\n \n 2023-08-17 16:11:36 UTC\n \n 2023-08-17 16:12:54 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2518\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:11:36',4,'2023-08-17 18:12:54',4,0,NULL,NULL,NULL,'b95e0670-059d-4690-986c-e7b162edc56a'),(2519,'Clients given 6C with Undetectable Viral Load','Clients given 6C with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with Undetectable Viral Load\n Clients given 6C with Undetectable Viral Load\n \n 2023-08-17 16:13:36 UTC\n \n 2023-08-17 16:14:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2519\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:13:36',4,'2023-08-17 18:14:33',4,0,NULL,NULL,NULL,'ef772750-6723-46e8-b1cd-2c843e8dd384'),(2520,'Clients given 6D with >=20Copies Viral Load','Clients given 6D with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with >=20Copies Viral Load\n Clients given 6D with >=20Copies Viral Load\n \n 2023-08-17 16:15:12 UTC\n \n 2023-08-17 16:16:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2520\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:15:12',4,'2023-08-17 18:16:15',4,0,NULL,NULL,NULL,'7067eaf1-d98c-4806-a595-c20526eb9695'),(2521,'Clients given 6D with <20 Copies Viral Load','Clients given 6D with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with <20 Copies Viral Load\n Clients given 6D with <20 Copies Viral Load\n \n 2023-08-17 16:17:05 UTC\n \n 2023-08-17 16:18:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2521\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:17:05',4,'2023-08-17 18:18:05',4,0,NULL,NULL,NULL,'cc8e5238-6071-4a37-b946-f6e9bf94dd26'),(2522,'Clients given 6D with Undetectable Viral Load','Clients given 6D with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with Undetectable Viral Load\n Clients given 6D with Undetectable Viral Load\n \n 2023-08-17 16:18:46 UTC\n \n 2023-08-17 16:19:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2522\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:18:46',4,'2023-08-17 18:19:45',4,0,NULL,NULL,NULL,'1df8beb0-cc67-496d-ba90-fa0dbc121691'),(2523,'Clients given 6E with >=20Copies Viral Load','Clients given 6E with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with >=20Copies Viral Load\n Clients given 6E with >=20Copies Viral Load\n \n 2023-08-17 16:20:29 UTC\n \n 2023-08-17 16:21:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2523\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:20:29',4,'2023-08-17 18:21:30',4,0,NULL,NULL,NULL,'6462e250-cf41-469a-83d7-e8b085ae587d'),(2524,'Clients given 6E with <20 Copies Viral Load','Clients given 6E with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with <20 Copies Viral Load\n Clients given 6E with <20 Copies Viral Load\n \n 2023-08-17 16:22:10 UTC\n \n 2023-08-17 16:24:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2524\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:22:10',4,'2023-08-17 18:24:14',4,0,NULL,NULL,NULL,'3492f4eb-af9b-448f-b4f1-fe314ce449f1'),(2525,'Children ARV Regimen_3rdLine_Adherence','Children ARV Regimen_3rdLine_Adherence','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_Adherence\n Children ARV Regimen_3rdLine_Adherence\n \n 2023-08-17 16:26:16 UTC\n \n 2023-08-17 16:26:28 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2525\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-17 18:26:16',4,'2023-08-17 18:26:28',4,0,NULL,NULL,NULL,'3262e4c0-f728-4cc8-ac30-b7413a14a644'),(2526,'Children ARV Regimen_3rdLine_Adherence Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_Adherence Data Set\n \n 2023-08-17 16:26:28 UTC\n \n 2023-08-17 16:38:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2526\n \n \n \n 6A_fair\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 6A_good\n \n \n \n \n \n \n \n \n \n 6A_poor\n \n \n \n \n \n \n \n \n \n 6B_fair\n \n \n \n \n \n \n \n \n \n 6B_good\n \n \n \n \n \n \n \n \n \n 6B_poor\n \n \n \n \n \n \n \n \n \n 6C_fair\n \n \n \n \n \n \n \n \n \n 6C_good\n \n \n \n \n \n \n \n \n \n 6C_poor\n \n \n \n \n \n \n \n \n \n 6D_fair\n \n \n \n \n \n \n \n \n \n 6D_good\n \n \n \n \n \n \n \n \n \n 6D_poor\n \n \n \n \n \n \n \n \n \n 6E_fair\n \n \n \n \n \n \n \n \n \n 6E_good\n \n \n \n \n \n \n \n \n \n 6E_poor\n \n \n \n \n \n \n \n \n \n 6F_fair\n \n \n \n \n \n \n \n \n \n 6F_good\n \n \n \n \n \n \n \n \n \n 6F_poor\n \n \n \n \n \n \n \n \n \n','2023-08-17 18:26:28',4,'2023-08-17 18:38:11',4,0,NULL,NULL,NULL,'9011d1b7-91da-465d-a4c7-38ea98126d13'),(2527,'Children ARV Regimen_2ndLine_Adherence','Children ARV Regimen_2ndLine_Adherence','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_Adherence\n Children ARV Regimen_2ndLine_Adherence\n \n 2023-08-17 16:40:24 UTC\n \n 2023-08-17 16:40:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2527\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-17 18:40:24',4,'2023-08-17 18:40:35',4,0,NULL,NULL,NULL,'ab24cc2a-a3ac-43a7-91c6-65bc90b27ae4'),(2528,'Children ARV Regimen_2ndLine_Adherence Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_Adherence Data Set\n \n 2023-08-17 16:40:35 UTC\n \n 2023-08-17 16:59:47 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2528\n \n \n \n 5A_fair\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 5A_good\n \n \n \n \n \n \n \n \n \n 5A_poor\n \n \n \n \n \n \n \n \n \n 5B_fair\n \n \n \n \n \n \n \n \n \n 5B_good\n \n \n \n \n \n \n \n \n \n 5B_poor\n \n \n \n \n \n \n \n \n \n 5C_fair\n \n \n \n \n \n \n \n \n \n 5C_good\n \n \n \n \n \n \n \n \n \n 5C_poor\n \n \n \n \n \n \n \n \n \n 5D_fair\n \n \n \n \n \n \n \n \n \n 5D_good\n \n \n \n \n \n \n \n \n \n 5D_poor\n \n \n \n \n \n \n \n \n \n 5E_fair\n \n \n \n \n \n \n \n \n \n 5E_good\n \n \n \n \n \n \n \n \n \n 5E_poor\n \n \n \n \n \n \n \n \n \n 5F_fair\n \n \n \n \n \n \n \n \n \n 5F_good\n \n \n \n \n \n \n \n \n \n 5F_poor\n \n \n \n \n \n \n \n \n \n 5G_fair\n \n \n \n \n \n \n \n \n \n 5G_good\n \n \n \n \n \n \n \n \n \n 5G_poor\n \n \n \n \n \n \n \n \n \n 5H_fair\n \n \n \n \n \n \n \n \n \n 5H_good\n \n \n \n \n \n \n \n \n \n 5H_poor\n \n \n \n \n \n \n \n \n \n','2023-08-17 18:40:35',4,'2023-08-17 18:59:47',4,0,NULL,NULL,NULL,'63956153-c9e8-480d-b057-96de951cf024'),(2529,'Clients given 6E with Undetectable Viral Load','Clients given 6E with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with Undetectable Viral Load\n Clients given 6E with Undetectable Viral Load\n \n 2023-08-17 16:48:58 UTC\n \n 2023-08-17 16:50:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2529\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:48:58',4,'2023-08-17 18:50:03',4,0,NULL,NULL,NULL,'836381fd-7adf-42ba-8ab4-01e9259a41f5'),(2530,'Clients given 6F with >=20Copies Viral Load','Clients given 6F with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with >=20Copies Viral Load\n Clients given 6F with >=20Copies Viral Load\n \n 2023-08-17 16:51:45 UTC\n \n 2023-08-17 16:53:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2530\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:51:45',4,'2023-08-17 18:53:52',4,0,NULL,NULL,NULL,'b8f0e53a-22a7-40e9-a9e6-e7ce266d4a19'),(2531,'Clients given 6F with <20 Copies Viral Load','Clients given 6F with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with <20 Copies Viral Load\n Clients given 6F with <20 Copies Viral Load\n \n 2023-08-17 16:55:01 UTC\n \n 2023-08-17 16:58:01 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2531\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:55:01',4,'2023-08-17 18:58:01',4,0,NULL,NULL,NULL,'b820ee3d-d805-468d-b7b4-2d1c5ce10a92'),(2532,'Children ARV Regimen_3rdLine_Viral_Load','Children ARV Regimen_3rdLine_Viral_Load','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_Viral_Load\n Children ARV Regimen_3rdLine_Viral_Load\n \n 2023-08-17 16:58:13 UTC\n \n 2023-08-17 16:58:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2532\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-17 18:58:13',4,'2023-08-17 18:58:43',4,0,NULL,NULL,NULL,'72eeaaa5-8c87-4939-a657-99b15cc3ab35'),(2533,'Children ARV Regimen_3rdLine_Viral_Load Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_Viral_Load Data Set\n \n 2023-08-17 16:58:43 UTC\n \n 2023-08-17 17:29:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2533\n \n \n \n 6A<20\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 6A>=20\n \n \n \n \n \n \n \n \n \n 6AUndetect\n \n \n \n \n \n \n \n \n \n 6B<20\n \n \n \n \n \n \n \n \n \n 6B>=20\n \n \n \n \n \n \n \n \n \n 6BUndetect\n \n \n \n \n \n \n \n \n \n 6C<20\n \n \n \n \n \n \n \n \n \n 6C>=20\n \n \n \n \n \n \n \n \n \n 6CUndetect\n \n \n \n \n \n \n \n \n \n 6D<20\n \n \n \n \n \n \n \n \n \n 6D>=20\n \n \n \n \n \n \n \n \n \n 6DUndetect\n \n \n \n \n \n \n \n \n \n 6E<20\n \n \n \n \n \n \n \n \n \n 6E>=20\n \n \n \n \n \n \n \n \n \n 6EUndetect\n \n \n \n \n \n \n \n \n \n 6F<20\n \n \n \n \n \n \n \n \n \n 6F>=20\n \n \n \n \n \n \n \n \n \n 6FUndetect\n \n \n \n \n \n \n \n \n \n','2023-08-17 18:58:43',4,'2023-08-17 19:29:02',4,0,NULL,NULL,NULL,'0a51f76b-0306-47fa-947d-55305024054a'),(2534,'Clients given 6F with Undetectable Viral Load','Clients given 6F with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with Undetectable Viral Load\n Clients given 6F with Undetectable Viral Load\n \n 2023-08-17 16:59:07 UTC\n \n 2023-08-17 17:02:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2534\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:59:07',4,'2023-08-17 19:02:35',4,0,NULL,NULL,NULL,'b1f06b90-64db-4554-8e81-989e206ed34a'),(2535,'Children ARV Regimen_2ndLine_Viral_Load','Children ARV Regimen_2ndLine_Viral_Load','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_Viral_Load\n Children ARV Regimen_2ndLine_Viral_Load\n \n 2023-08-17 17:06:27 UTC\n \n 2023-08-17 17:06:48 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2535\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-17 19:06:27',4,'2023-08-17 19:06:48',4,0,NULL,NULL,NULL,'701df245-5766-4e37-9d54-89e6ecedb217'),(2536,'Children ARV Regimen_2ndLine_Viral_Load Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_Viral_Load Data Set\n \n 2023-08-17 17:06:48 UTC\n \n 2023-08-17 17:26:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2536\n \n \n \n 5A_Undetec\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 5A<20\n \n \n \n \n \n \n \n \n \n 5A>=20\n \n \n \n \n \n \n \n \n \n 5B_Undetec\n \n \n \n \n \n \n \n \n \n 5B<20\n \n \n \n \n \n \n \n \n \n 5B>=20\n \n \n \n \n \n \n \n \n \n 5C_Undetec\n \n \n \n \n \n \n \n \n \n 5C<20\n \n \n \n \n \n \n \n \n \n 5C>=20\n \n \n \n \n \n \n \n \n \n 5E_Undetec\n \n \n \n \n \n \n \n \n \n 5E<20\n \n \n \n \n \n \n \n \n \n 5E>=20\n \n \n \n \n \n \n \n \n \n 5F_Undetec\n \n \n \n \n \n \n \n \n \n 5F<20\n \n \n \n \n \n \n \n \n \n 5F>=20\n \n \n \n \n \n \n \n \n \n 5G_Undetec\n \n \n \n \n \n \n \n \n \n 5G<20\n \n \n \n \n \n \n \n \n \n 5G>=20\n \n \n \n \n \n \n \n \n \n 5H_Undetec\n \n \n \n \n \n \n \n \n \n 5H<20\n \n \n \n \n \n \n \n \n \n 5H>=20\n \n \n \n \n \n \n \n \n \n','2023-08-17 19:06:48',4,'2023-08-17 19:26:20',4,0,NULL,NULL,NULL,'2790255e-587f-411d-9f8a-dbca36aa7e0d'),(2537,'ART clients with visits started','ART clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with visits started\n ART clients with visits started\n \n 2023-09-21 12:40:58 UTC\n \n 2023-09-21 12:41:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2537\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n LEFT JOIN patient_identifier pi ON v.patient_id = pi.patient_id AND pi.identifier_type in (5,12) \n JOIN patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1, 2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id and vt.visit_type_id in (10,19) \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:40:58',4,'2023-09-21 14:41:15',4,0,NULL,NULL,NULL,'5de36ef7-faa8-422d-943d-fdd6ad3497a0'),(2538,'ART clients with visits consulted','ART clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with visits consulted\n ART clients with visits consulted\n \n 2023-09-21 12:41:53 UTC\n \n 2023-09-21 12:42:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2538\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n LEFT JOIN patient_identifier pi ON v.patient_id = pi.patient_id AND pi.identifier_type in (5,12) \n JOIN patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id and vt.visit_type_id in (10,19) \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id in (3843, 4276) and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:41:53',4,'2023-09-21 14:42:05',4,0,NULL,NULL,NULL,'9340a449-ab16-4a98-8dcb-240635a9042d'),(2539,'Clients initiated on ART this month','Clients initiated on ART this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients initiated on ART this month\n Clients initiated on ART this month\n \n 2023-09-21 12:42:21 UTC\n \n 2023-09-21 12:43:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2539\n select distinct patient.patient_id AS Id \n \n from obs o \n -- CLIENTS NEWLY INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 \n \n AND MONTH(o.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id not in ( \n select distinct os.person_id from obs os \n where os.concept_id = 3634 \n AND os.value_coded = 2095 \n and os.voided = 0 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and o.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages'\n','2023-09-21 14:42:21',4,'2023-09-21 14:43:10',4,0,NULL,NULL,NULL,'d3e386aa-99a9-4463-9e81-f663ca35cad2'),(2540,'TB clients with visits started','TB clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB clients with visits started\n TB clients with visits started\n \n 2023-09-21 12:42:50 UTC\n \n 2023-09-21 12:43:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2540\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 13 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:42:50',4,'2023-09-21 14:43:05',4,0,NULL,NULL,NULL,'e6d2d518-2160-4fc8-84dc-a680c609b27f'),(2541,'TB clients with visits consulted','TB clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB clients with visits consulted\n TB clients with visits consulted\n \n 2023-09-21 12:44:18 UTC\n \n 2023-09-21 12:45:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2541\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id in (4153,1158) and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 13 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:44:18',4,'2023-09-21 14:45:05',4,0,NULL,NULL,NULL,'d205535e-f890-488a-a256-a69835a9a9d8'),(2542,'HTS Clients Seen','HTS Clients Seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Clients Seen\n HTS Clients Seen\n \n 2023-09-21 12:45:02 UTC\n \n 2023-09-21 12:45:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2542\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in( \nSELECT Id \nFROM ( \n select distinct o.person_id as Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where o.concept_id = 4845 and o.value_coded = 4847 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n ) as A \n)\n','2023-09-21 14:45:02',4,'2023-09-21 14:45:39',4,0,NULL,NULL,NULL,'ce0fbba8-f81e-4f15-9da5-b341fd68b611'),(2543,'HTS clients with visits started','HTS clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS clients with visits started\n HTS clients with visits started\n \n 2023-09-21 12:45:52 UTC\n \n 2023-09-21 12:46:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2543\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 15 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:45:52',4,'2023-09-21 14:46:05',4,0,NULL,NULL,NULL,'fe7fb845-5325-4d00-8cab-7041e6759f04'),(2544,'1st Postnatal (PNC) Attendance','1st Postnatal (PNC) Attendance','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 1st Postnatal (PNC) Attendance\n 1st Postnatal (PNC) Attendance\n \n 2023-09-21 12:46:47 UTC\n \n 2023-09-21 12:47:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2544\n select \n o.person_id \nfrom obs o \ninner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4393 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4393 \n and o.obs_datetime = max_observation\n','2023-09-21 14:46:47',4,'2023-09-21 14:47:10',4,0,NULL,NULL,NULL,'290d3497-9608-4796-9826-1dc624696dbd'),(2545,'HTS clients with visits consulted','HTS clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS clients with visits consulted\n HTS clients with visits consulted\n \n 2023-09-21 12:47:27 UTC\n \n 2023-09-21 12:47:54 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2545\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4238 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 15 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:47:27',4,'2023-09-21 14:47:54',4,0,NULL,NULL,NULL,'35051ec1-423c-4ede-a68f-88e94f2dc6a2'),(2546,'Self test Kits distributed','Self test Kits distributed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Self test Kits distributed\n Self test Kits distributed\n \n 2023-09-21 12:48:21 UTC\n \n 2023-09-21 12:48:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2546\n (select patient.patient_id AS Id \n from obs o \n -- HTS SELF TEST STRATEGY \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n AND o.concept_id = 4833 and o.value_coded = 4834 \n AND patient.voided = 0 AND o.voided = 0 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n ) \n \nUNION ALL \n(select patient.patient_id AS Id \n from obs o \n -- HTS SELF TEST STRATEGY \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n AND o.concept_id = 4836 and o.value_coded in (4837, 4838, 4839) \n AND patient.voided = 0 AND o.voided = 0 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n )\n','2023-09-21 14:48:21',4,'2023-09-21 14:48:36',4,0,NULL,NULL,NULL,'4ef31fd0-53cc-4296-adc1-1b74455e2a5f'),(2547,'ANC clients with visits started','ANC clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with visits started\n ANC clients with visits started\n \n 2023-09-21 12:49:04 UTC\n \n 2023-09-21 12:49:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2547\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 16 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:49:04',4,'2023-09-21 14:49:44',4,0,NULL,NULL,NULL,'928922c7-633f-4cb0-9149-88ae7e50e237'),(2548,'Under5 Clients Seen','Under5 Clients Seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under5 Clients Seen\n Under5 Clients Seen\n \n 2023-09-21 12:49:57 UTC\n \n 2023-09-21 12:50:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2548\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in( \nSELECT Id \nFROM ( \n select distinct o.person_id as Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where o.concept_id = 4285 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n ) as A \n)\n','2023-09-21 14:49:57',4,'2023-09-21 14:50:12',4,0,NULL,NULL,NULL,'93a89f3f-f556-4592-b12e-cf8849d58b58'),(2549,'ANC clients with visits consulted','ANC clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with visits consulted\n ANC clients with visits consulted\n \n 2023-09-21 12:50:25 UTC\n \n 2023-09-21 12:51:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2549\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4663 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 16 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:50:25',4,'2023-09-21 14:51:08',4,0,NULL,NULL,NULL,'ab0560b8-8a8b-4759-983b-d3b0d69afafa'),(2550,'HEI Clients Seen','HEI Clients Seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI Clients Seen\n HEI Clients Seen\n \n 2023-09-21 12:51:29 UTC\n \n 2023-09-21 12:51:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2550\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in( \nSELECT Id \nFROM ( \n select distinct o.person_id as Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where o.concept_id = 4558 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n ) as A \n)\n','2023-09-21 14:51:29',4,'2023-09-21 14:51:43',4,0,NULL,NULL,NULL,'f8e02920-02de-4c2b-9b44-6974b937b51c'),(2551,'PNC clients with visits started','PNC clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PNC clients with visits started\n PNC clients with visits started\n \n 2023-09-21 12:51:49 UTC\n \n 2023-09-21 12:52:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2551\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 17 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:51:49',4,'2023-09-21 14:52:21',4,0,NULL,NULL,NULL,'dddf7e03-38fe-419f-81a4-625dabb0fd4e'),(2552,'Family Planning Clients seen','Family Planning Clients seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning Clients seen\n Family Planning Clients seen\n \n 2023-09-21 12:52:28 UTC\n \n 2023-09-21 12:52:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2552\n select \n o.person_id \nfrom obs o \ninner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4557 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4557 \n and o.obs_datetime = max_observation\n','2023-09-21 14:52:28',4,'2023-09-21 14:52:43',4,0,NULL,NULL,NULL,'287d14af-8d53-48d0-8cf4-47f141b0e9ea'),(2553,'PNC clients with visits consulted','PNC clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PNC clients with visits consulted\n PNC clients with visits consulted\n \n 2023-09-21 12:52:50 UTC\n \n 2023-09-21 12:53:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2553\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4386 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 17 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:52:50',4,'2023-09-21 14:53:03',4,0,NULL,NULL,NULL,'bf6795b4-6d7f-49bd-aff7-53781f102898'),(2554,'Cervical Cancer Screening clients seen','Cervical Cancer Screening clients seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients seen\n Cervical Cancer Screening clients seen\n \n 2023-09-21 12:53:29 UTC\n \n 2023-10-17 13:11:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2554\n select \n o.person_id \nfrom obs o \ninner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4511 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4511 \n and o.obs_datetime = max_observation\n','2023-09-21 18:23:29',4,'2023-10-17 18:41:36',4,0,NULL,NULL,NULL,'f436cc71-62c7-413d-81b3-0f6bbad88a73'),(2555,'HEI clients with visits started','HEI clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI clients with visits started\n HEI clients with visits started\n \n 2023-09-21 12:54:17 UTC\n \n 2023-09-21 12:54:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2555\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 18 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:54:17',4,'2023-09-21 14:54:29',4,0,NULL,NULL,NULL,'e26ba5ce-54c6-4693-8f0c-52aae22ce97b'),(2556,'ANC Clients Seen','ANC Clients Seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients Seen\n ANC Clients Seen\n \n 2023-09-21 12:54:42 UTC\n \n 2023-09-21 12:54:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2556\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in( \nSELECT Id \nFROM ( \n select distinct o.person_id as Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where o.concept_id = 4663 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n ) as A \n)\n','2023-09-21 14:54:42',4,'2023-09-21 14:54:57',4,0,NULL,NULL,NULL,'f58dd29e-bfcf-411a-a5fa-789722177fd1'),(2557,'HEI clients with visits consulted','HEI clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI clients with visits consulted\n HEI clients with visits consulted\n \n 2023-09-21 12:55:13 UTC\n \n 2023-09-21 12:56:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2557\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id in (4558, 4186) and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 18 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:55:13',4,'2023-09-21 14:56:33',4,0,NULL,NULL,NULL,'2bcc29bb-b22f-4866-8035-f7f1db1ead87'),(2558,'ANC Clients Seen','ANC Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients Seen\n ANC Clients Seen\n \n 2023-09-21 12:55:47 UTC\n \n 2023-09-21 12:56:41 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2558\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 14:55:47',4,'2023-09-21 14:56:41',4,0,NULL,NULL,NULL,'7006c9eb-caa2-4617-9151-d6872b35e3a1'),(2559,'Cervical Cancer Screening clients seen','Cervical Cancer Screening clients seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients seen\n Cervical Cancer Screening clients seen\n \n 2023-09-21 12:57:08 UTC\n \n 2023-09-21 12:57:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2559\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 14:57:08',4,'2023-09-21 14:57:52',4,0,NULL,NULL,NULL,'697c637f-d0ae-45a2-9eab-f4f9012c2412'),(2560,'Family Planning clients with visits started','Family Planning clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning clients with visits started\n Family Planning clients with visits started\n \n 2023-09-21 12:57:35 UTC\n \n 2023-09-21 12:57:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2560\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 22 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:57:35',4,'2023-09-21 14:57:59',4,0,NULL,NULL,NULL,'a713664a-9547-4de1-bcea-eab77e351ec5'),(2561,'Family Planning Clients seen','Family Planning Clients seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning Clients seen\n Family Planning Clients seen\n \n 2023-09-21 12:58:35 UTC\n \n 2023-09-21 12:59:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2561\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 14:58:35',4,'2023-09-21 14:59:30',4,0,NULL,NULL,NULL,'4934d5cb-a141-4144-9937-59b8bb142789'),(2562,'Family Planning clients with visits consulted','Family Planning clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning clients with visits consulted\n Family Planning clients with visits consulted\n \n 2023-09-21 12:58:46 UTC\n \n 2023-09-21 12:59:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2562\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4557 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 22 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:58:46',4,'2023-09-21 14:59:18',4,0,NULL,NULL,NULL,'ada60155-c22d-4ad4-b960-45bb814acd47'),(2563,'HEI Clients Seen','HEI Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI Clients Seen\n HEI Clients Seen\n \n 2023-09-21 12:59:50 UTC\n \n 2023-09-21 13:00:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2563\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 14:59:50',4,'2023-09-21 15:00:32',4,0,NULL,NULL,NULL,'8f5713d9-1797-48ed-92ba-7a6bbc3f02be'),(2564,'Under 5 clients with visits started','Under 5 clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under 5 clients with visits started\n Under 5 clients with visits started\n \n 2023-09-21 12:59:58 UTC\n \n 2023-09-21 13:00:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2564\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 20 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:59:58',4,'2023-09-21 15:00:12',4,0,NULL,NULL,NULL,'b569e5c1-aab8-4a67-955c-b09d0c5c1b6b'),(2565,'Under 5 clients with visits consulted','Under 5 clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under 5 clients with visits consulted\n Under 5 clients with visits consulted\n \n 2023-09-21 13:00:57 UTC\n \n 2023-09-21 13:01:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2565\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4285 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 20 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 15:00:57',4,'2023-09-21 15:01:12',4,0,NULL,NULL,NULL,'ae2b5eee-422b-4307-a985-7bd763147582'),(2566,'HTS Clients Seen','HTS Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Clients Seen\n HTS Clients Seen\n \n 2023-09-21 13:00:59 UTC\n \n 2023-09-21 13:01:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2566\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:00:59',4,'2023-09-21 15:01:59',4,0,NULL,NULL,NULL,'198319c7-6986-4599-8b2a-886ed81d7c37'),(2567,'1st Postnatal (PNC) Attendance','1st Postnatal (PNC) Attendance','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 1st Postnatal (PNC) Attendance\n 1st Postnatal (PNC) Attendance\n \n 2023-09-21 13:01:44 UTC\n \n 2023-09-21 13:02:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2567\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:01:44',4,'2023-09-21 15:02:26',4,0,NULL,NULL,NULL,'07589d1a-d289-491c-a8dd-ac6e506b6eca'),(2568,'Cervical Cancer Screening clients with visits started','Cervical Cancer Screening clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients with visits started\n Cervical Cancer Screening clients with visits started\n \n 2023-09-21 13:02:00 UTC\n \n 2023-09-21 13:02:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2568\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 21 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 15:02:00',4,'2023-09-21 15:02:14',4,0,NULL,NULL,NULL,'4f7cc18d-1104-4427-b582-f73b99bd0837'),(2569,'Self test Kits distributed','Self test Kits distributed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Self test Kits distributed\n Self test Kits distributed\n \n 2023-09-21 13:02:50 UTC\n \n 2023-09-21 13:04:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2569\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:02:50',4,'2023-09-21 15:04:03',4,0,NULL,NULL,NULL,'5cc879f5-78be-4f74-9cd0-06ae596deffe'),(2570,'Cervical Cancer Screening clients with visits consulted','Cervical Cancer Screening clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients with visits consulted\n Cervical Cancer Screening clients with visits consulted\n \n 2023-09-21 13:02:56 UTC\n \n 2023-09-21 13:03:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2570\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4511 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 21 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 15:02:56',4,'2023-09-21 15:03:08',4,0,NULL,NULL,NULL,'cf21c6a3-0a19-44c7-b2c7-e14246d7bc96'),(2571,'Under5 Clients Seen','Under5 Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under5 Clients Seen\n Under5 Clients Seen\n \n 2023-09-21 13:03:36 UTC\n \n 2023-09-21 13:05:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2571\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:03:36',4,'2023-09-21 15:05:20',4,0,NULL,NULL,NULL,'d8654256-acae-40b0-a3c2-feafeb2f36ad'),(2572,'eRegister Monitoring Report','eRegister Monitoring Report','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n eRegister Monitoring Report\n eRegister Monitoring Report\n \n 2023-09-21 13:06:13 UTC\n \n 2023-09-21 13:26:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2572\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-09-21 15:06:13',4,'2023-09-21 15:26:06',4,0,NULL,NULL,NULL,'a9290709-3dd9-4bfe-823d-b1702d10ec0f'),(2573,'eRegister Monitoring Report Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n eRegister Monitoring Report Data Set\n \n 2023-09-21 13:06:21 UTC\n \n 2023-09-22 08:47:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2573\n \n \n \n ANC_Consul\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n ANC_Seen\n \n \n \n \n \n \n \n \n \n ANC_Visits\n \n \n \n \n \n \n \n \n \n ART_Consul\n \n \n \n \n \n \n \n \n \n ART_Visits\n \n \n \n \n \n \n \n \n \n Cerv_Consu\n \n \n \n \n \n \n \n \n \n Cerv_Scree\n \n \n \n \n \n \n \n \n \n Cerv_Visit\n \n \n \n \n \n \n \n \n \n ClntsOnArt\n \n \n \n \n \n \n \n \n \n FP_Consult\n \n \n \n \n \n \n \n \n \n FP_Seen\n \n \n \n \n \n \n \n \n \n FP_Visits\n \n \n \n \n \n \n \n \n \n HEI_Consul\n \n \n \n \n \n \n \n \n \n HEI_Seen\n \n \n \n \n \n \n \n \n \n HEI_Visits\n \n \n \n \n \n \n \n \n \n HTS_Consul\n \n \n \n \n \n \n \n \n \n HTS_Seen\n \n \n \n \n \n \n \n \n \n HTS_Visits\n \n \n \n \n \n \n \n \n \n LTest_Rev\n \n \n \n \n \n \n \n \n \n LTest_Sent\n \n \n \n \n \n \n \n \n \n PNC_Attend\n \n \n \n \n \n \n \n \n \n PNC_Consul\n \n \n \n \n \n \n \n \n \n PNC_Visits\n \n \n \n \n \n \n \n \n \n Self_tes_D\n \n \n \n \n \n \n \n \n \n TB_Consult\n \n \n \n \n \n \n \n \n \n TB_Visits\n \n \n \n \n \n \n \n \n \n Tx_New\n \n \n \n \n \n \n \n \n \n Under5_Con\n \n \n \n \n \n \n \n \n \n Under5_See\n \n \n \n \n \n \n \n \n \n Under5_Vis\n \n \n \n \n \n \n \n \n \n','2023-09-21 13:06:21',4,'2023-09-22 08:47:46',4,0,NULL,NULL,NULL,'a971d8e2-a66a-487c-aae4-36c6f14a3328'),(2574,' ANC clients with visits started',' ANC clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with visits started\n ANC clients with visits started\n \n 2023-09-21 13:07:00 UTC\n \n 2023-09-21 13:07:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2574\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:07:00',4,'2023-09-21 15:07:46',4,0,NULL,NULL,NULL,'69485106-52a5-452e-91ef-6ecf80894a7f'),(2575,'ART clients with visits consulted','ART clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with visits consulted\n ART clients with visits consulted\n \n 2023-09-21 13:08:16 UTC\n \n 2023-09-21 13:08:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2575\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:08:16',4,'2023-09-21 15:08:50',4,0,NULL,NULL,NULL,'7cce44cb-0809-4493-84bb-2fdbe745ceab'),(2576,'ART clients with visits started','ART clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with visits started\n ART clients with visits started\n \n 2023-09-21 13:09:47 UTC\n \n 2023-09-21 13:11:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2576\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:09:47',4,'2023-09-21 15:11:10',4,0,NULL,NULL,NULL,'a5551436-00f8-45c4-aa3b-6aaae3160f55'),(2577,'Clients initiated on ART this month','Clients initiated on ART this month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients initiated on ART this month\n Clients initiated on ART this month\n \n 2023-09-21 13:11:24 UTC\n \n 2023-09-21 13:12:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2577\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:11:24',4,'2023-09-21 15:12:20',4,0,NULL,NULL,NULL,'e6b92d7a-5f7e-4001-957e-30b6be452168'),(2578,'ANC clients with visits consulted','ANC clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with visits consulted\n ANC clients with visits consulted\n \n 2023-09-21 13:11:45 UTC\n \n 2023-09-21 13:12:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2578\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:11:45',4,'2023-09-21 15:12:58',4,0,NULL,NULL,NULL,'5c7fcfb9-3d39-4225-a4f3-8ed358e16626'),(2579,'TB clients with visits started','TB clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB clients with visits started\n TB clients with visits started\n \n 2023-09-21 13:13:10 UTC\n \n 2023-09-21 13:13:56 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2579\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:13:10',4,'2023-09-21 15:13:56',4,0,NULL,NULL,NULL,'09767de3-79b3-43e2-82da-339278f5e10d'),(2580,'TB clients with visits consulted','TB clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB clients with visits consulted\n TB clients with visits consulted\n \n 2023-09-21 13:14:13 UTC\n \n 2023-09-21 13:16:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2580\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:14:13',4,'2023-09-21 15:16:03',4,0,NULL,NULL,NULL,'d4ae74d3-d618-4e3b-8d10-4c54e5f3b75a'),(2581,'HTS clients with visits started','HTS clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS clients with visits started\n HTS clients with visits started\n \n 2023-09-21 13:16:45 UTC\n \n 2023-09-21 13:17:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2581\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:16:45',4,'2023-09-21 15:17:18',4,0,NULL,NULL,NULL,'91f470f1-71bf-4a21-bd12-efe0fe142c0a'),(2582,'HTS clients with visits consulted','HTS clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS clients with visits consulted\n HTS clients with visits consulted\n \n 2023-09-21 13:17:44 UTC\n \n 2023-09-21 13:18:19 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2582\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:17:44',4,'2023-09-21 15:18:19',4,0,NULL,NULL,NULL,'2bd858aa-2daf-4fd2-9028-9d6fba579a89'),(2583,'PNC clients with visits started','PNC clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PNC clients with visits started\n PNC clients with visits started\n \n 2023-09-21 13:18:49 UTC\n \n 2023-09-21 13:19:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2583\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:18:49',4,'2023-09-21 15:19:20',4,0,NULL,NULL,NULL,'80003d94-268b-4726-ba0d-0fa830e90463'),(2584,'PNC clients with visits consulted','PNC clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PNC clients with visits consulted\n PNC clients with visits consulted\n \n 2023-09-21 13:19:39 UTC\n \n 2023-09-21 13:20:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2584\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:19:39',4,'2023-09-21 15:20:18',4,0,NULL,NULL,NULL,'e64fd32d-8284-4fb5-a227-8f338859ceaa'),(2586,'HEI clients with visits started','HEI clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI clients with visits started\n HEI clients with visits started\n \n 2023-09-21 13:23:38 UTC\n \n 2023-09-21 13:24:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2586\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:23:38',4,'2023-09-21 15:24:10',4,0,NULL,NULL,NULL,'e7e581aa-9b90-4f56-b8a1-9bfc607f8b4f'),(2587,'HEI clients with visits consulted','HEI clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI clients with visits consulted\n HEI clients with visits consulted\n \n 2023-09-21 13:24:38 UTC\n \n 2023-09-21 13:25:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2587\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:24:38',4,'2023-09-21 15:25:05',4,0,NULL,NULL,NULL,'dd05778e-c5bd-4430-90fa-fd97b36402d2'),(2588,'Family Planning clients with visits started','Family Planning clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning clients with visits started\n Family Planning clients with visits started\n \n 2023-09-21 13:25:31 UTC\n \n 2023-09-21 13:26:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2588\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:25:31',4,'2023-09-21 15:26:32',4,0,NULL,NULL,NULL,'3278fb6f-2276-4390-a5c2-9863d056f3a0'),(2589,'Family Planning clients with visits consulted','Family Planning clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning clients with visits consulted\n Family Planning clients with visits consulted\n \n 2023-09-21 13:26:58 UTC\n \n 2023-09-21 13:27:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2589\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:26:58',4,'2023-09-21 15:27:32',4,0,NULL,NULL,NULL,'822f0677-6a2b-47cf-9265-0841d65e9716'),(2590,'Under 5 clients with visits consulted','Under 5 clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under 5 clients with visits consulted\n Under 5 clients with visits consulted\n \n 2023-09-21 13:28:28 UTC\n \n 2023-09-21 13:31:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2590\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:28:28',4,'2023-09-21 15:31:36',4,0,NULL,NULL,NULL,'3a2857b0-1d9c-4f7d-95e9-abcba540935d'),(2591,'Under 5 clients with visits started','Under 5 clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under 5 clients with visits started\n Under 5 clients with visits started\n \n 2023-09-21 13:30:05 UTC\n \n 2023-09-21 13:30:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2591\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:30:05',4,'2023-09-21 15:30:36',4,0,NULL,NULL,NULL,'f62e6fdd-a64b-4619-925c-d86fc3987060'),(2592,'Clients current on ART','Clients current on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients current on ART\n Clients current on ART\n \n 2023-09-21 13:31:58 UTC\n \n 2023-09-21 13:35:41 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2592\n (SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- CLIENTS NEWLY INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 \n \n AND MONTH(o.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id not in ( \n select distinct os.person_id from obs os \n where os.concept_id = 3634 \n AND os.value_coded = 2095 \n and os.voided = 0 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and o.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages') AS Newly_Initiated_ART_Clients \nORDER BY Newly_Initiated_ART_Clients.patientName) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 3843 AND o.value_coded = 3841 OR o.value_coded = 3842) \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND patient.voided = 0 AND o.voided = 0 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n \n) AS Clients_Seen \n \nWHERE Clients_Seen.Id not in ( \n select distinct patient.patient_id AS Id \n from obs o \n -- CLIENTS INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 \n AND MONTH(o.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id not in ( \n select distinct os.person_id from obs os \n where os.concept_id = 3634 \n AND os.value_coded = 2095 \n and os.voided = 0 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n ) \nAND Clients_Seen.Id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 and os.voided = 0 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 and os.voided = 0 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \nAND Clients_Seen.Id not in \n ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 and os.voided = 0 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) \n and o.person_id in ( \n -- Death \n select distinct p.person_id \n from person p \n where dead = 1 \n and death_date <= CAST(:endDate AS DATE) \n and voided = 0 \n ) \n ) \nAND Clients_Seen.Id not in ( \n -- Visitors \n select o.person_id \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 5416 and oss.value_coded =1 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 5416 \n and o.obs_datetime = max_observation \n ) \n \nORDER BY Clients_Seen.patientName) \n \nUNION \n \n \n-- INCLUDE MISSED APPOINTMENTS WITHIN 28 DAYS ACCORDING TO THE NEW PEPFAR GUIDELINE \n(SELECT Id \nFROM \n (select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- CLIENTS WHO MISSED APPOINTMENTS < 28 DAYS \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n -- begin \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up < cast(:endDate as date) \n and DATEDIFF(CAST(:endDate AS DATE),latest_follow_up) <= 28 \n \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 3843 AND os.value_coded = 3841 OR os.value_coded = 3842) \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n \n -- TOUTS \n select tout_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.obs_datetime AS latest_consultation \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(max(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 2403 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 2398 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as tout_clients \n where tout_clients.latest_consultation < cast(:endDate as date) \n \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n \n ) \n \n and active_clients.person_id not in( \n -- Visitors \n select o.person_id \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 5416 and oss.value_coded =1 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 5416 \n and o.obs_datetime = max_observation \n ) \n ) \n -- end \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages') AS TwentyEightDayDefaulters \n order by TwentyEightDayDefaulters.patientName) \n \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n -- begin \n select active_clients.person_id-- , active_clients.latest_follow_up \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 3843 AND os.value_coded = 3841 OR os.value_coded = 3842) \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 and os.voided = 0 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 and os.voided = 0 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select o.person_id \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 5416 and oss.value_coded =1 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 5416 \n and o.obs_datetime = max_observation \n ) \n ) \n -- end \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages') AS Seen_Previous_ART_Clients \nORDER BY Seen_Previous_ART_Clients.patientName) \n\n','2023-09-21 15:31:58',4,'2023-09-21 15:35:41',4,0,NULL,NULL,NULL,'ad403c3b-d759-44ab-8965-252ca6127ce7'),(2593,'Cervical Cancer Screening clients with visits started','Cervical Cancer Screening clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients with visits started\n Cervical Cancer Screening clients with visits started\n \n 2023-09-21 13:32:10 UTC\n \n 2023-09-21 13:32:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2593\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:32:10',4,'2023-09-21 15:32:43',4,0,NULL,NULL,NULL,'c7967fcd-a8b7-41d4-b540-364a60a59621'),(2594,'Cervical Cancer Screening clients with visits consulted','Cervical Cancer Screening clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients with visits consulted\n Cervical Cancer Screening clients with visits consulted\n \n 2023-09-21 13:33:06 UTC\n \n 2023-09-21 13:34:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2594\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:33:06',4,'2023-09-21 15:34:03',4,0,NULL,NULL,NULL,'b526566e-555d-40c6-88d4-0b89242b1dde'),(2595,'Clients current on ART','Clients current on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients current on ART\n Clients current on ART\n \n 2023-09-21 13:36:28 UTC\n \n 2023-09-21 13:37:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2595\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:36:28',4,'2023-09-21 15:37:08',4,0,NULL,NULL,NULL,'1db1c64d-177f-4ecc-b1d7-c9fd2b029eff'),(2596,'Clients with LAB tests sent','Clients with LAB tests sent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with LAB tests sent\n Clients with LAB tests sent\n \n 2023-09-22 08:35:11 UTC\n \n 2023-09-22 08:35:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2596\n select distinct patient.patient_id AS Id \n from orders o \n INNER JOIN patient ON o.patient_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n AND o.concept_id = 5484 \n AND CAST(o.date_created AS DATE)>= CAST(:startDate AS DATE) \n AND CAST(o.date_created AS DATE) <= CAST(:endDate AS DATE) \n LEFT OUTER JOIN patient_identifier p ON p.patient_id = person.person_id AND p.identifier_type = 5\n','2023-09-22 08:35:11',4,'2023-09-22 08:35:51',4,0,NULL,NULL,NULL,'f06f1ccb-c048-44d3-8037-35f8660a6b95'),(2597,'Clients with LAB tests sent','Clients with LAB tests sent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with LAB tests sent\n Clients with LAB tests sent\n \n 2023-09-22 08:36:30 UTC\n \n 2023-09-22 08:38:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2597\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-22 08:36:30',4,'2023-09-22 08:38:26',4,0,NULL,NULL,NULL,'c29cff5d-5919-4b60-8ab7-c6d4c7ea01da'),(2598,'Clients with LAB tests received','Clients with LAB tests received','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with LAB tests received\n Clients with LAB tests received\n \n 2023-09-22 08:39:02 UTC\n \n 2023-09-22 08:39:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2598\n select o.person_id \nfrom obs o \ninner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.obs_id)), 20) as observation_id \n from obs oss \n where oss.concept_id = 5486 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast('#startDate#' as date) \n and cast(oss.obs_datetime as date) <= cast('#endDate#' as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where o.concept_id = 5486 \n and o.obs_datetime = max_observation\n','2023-09-22 08:39:02',4,'2023-09-22 08:39:21',4,0,NULL,NULL,NULL,'6939902b-1909-4f24-b71d-da60ab1d131b'),(2599,'Clients with LAB tests received','Clients with LAB tests received','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with LAB tests received\n Clients with LAB tests received\n \n 2023-09-22 08:39:53 UTC\n \n 2023-09-22 08:42:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2599\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-22 08:39:53',4,'2023-09-22 08:42:39',4,0,NULL,NULL,NULL,'e47a29f8-b851-480f-9812-e54da393fdb9'); +INSERT INTO `serialized_object` VALUES (2509,'Clients given 6e with poor adherence','Clients given 6e with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with poor adherence\n Clients given 6e with poor adherence\n \n 2023-08-17 15:19:01 UTC\n \n 2023-08-17 15:20:53 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2509\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:19:01',4,'2023-08-17 17:20:53',4,0,NULL,NULL,NULL,'8c2c0191-d6e6-4f9c-a84d-976f24a47e5a'),(2510,'Clients given 6e with fair adherence','Clients given 6e with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with fair adherence\n Clients given 6e with fair adherence\n \n 2023-08-17 15:20:17 UTC\n \n 2023-08-17 15:22:00 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2510\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:20:17',4,'2023-08-17 17:22:00',4,0,NULL,NULL,NULL,'16552ea9-b4bb-4ae3-ae13-c04d366a5a72'),(2511,'Clients given 6e with good adherence','Clients given 6e with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6e with good adherence\n Clients given 6e with good adherence\n \n 2023-08-17 15:21:28 UTC\n \n 2023-08-17 15:23:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2511\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:21:28',4,'2023-08-17 17:23:08',4,0,NULL,NULL,NULL,'ca215c1b-6a15-42a3-b752-9ce21c651e13'),(2512,'Clients given 6f with poor adherence','Clients given 6f with poor adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with poor adherence\n Clients given 6f with poor adherence\n \n 2023-08-17 15:22:56 UTC\n \n 2023-08-17 15:24:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2512\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:22:56',4,'2023-08-17 17:24:10',4,0,NULL,NULL,NULL,'ba0a85d0-9c18-49b9-8c42-417c8d96221c'),(2513,'Clients given 6f with fair adherence','Clients given 6f with fair adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with fair adherence\n Clients given 6f with fair adherence\n \n 2023-08-17 15:23:41 UTC\n \n 2023-08-17 15:25:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2513\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:23:41',4,'2023-08-17 17:25:35',4,0,NULL,NULL,NULL,'7abe4ec4-ba33-4f66-97c3-33ffd356c478'),(2514,'Clients given 6f with good adherence','Clients given 6f with good adherence','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6f with good adherence\n Clients given 6f with good adherence\n \n 2023-08-17 15:25:08 UTC\n \n 2023-08-17 15:27:07 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2514\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 17:25:08',4,'2023-08-17 17:27:07',4,0,NULL,NULL,NULL,'605e06e0-b274-46a5-8404-e45f6bdbf36d'),(2515,'Clients given 6B with <20 Copies Viral Load','Clients given 6B with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B with <20 Copies Viral Load\n Clients given 6B with <20 Copies Viral Load\n \n 2023-08-17 16:05:27 UTC\n \n 2023-08-17 16:06:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2515\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:05:27',4,'2023-08-17 18:06:26',4,0,NULL,NULL,NULL,'57a592d4-f5a1-4ac8-afd9-dbabd8335120'),(2516,'Clients given 6B with Undetectable Viral Load','Clients given 6B with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6B with Undetectable Viral Load\n Clients given 6B with Undetectable Viral Load\n \n 2023-08-17 16:07:16 UTC\n \n 2023-08-17 17:13:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2516\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:07:16',4,'2023-08-17 19:13:12',4,0,NULL,NULL,NULL,'9a6c692c-675e-490a-827d-788308c41aa2'),(2517,'Clients given 6C with >=20 Copies Viral Load','Clients given 6C with >=20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with >=20 Copies Viral Load\n Clients given 6C with >=20 Copies Viral Load\n \n 2023-08-17 16:09:20 UTC\n \n 2023-08-17 16:10:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2517\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:09:20',4,'2023-08-17 18:10:11',4,0,NULL,NULL,NULL,'2b0f18d1-d6bc-48db-81e9-139e7127a014'),(2518,'Clients given 6C with <20 Copies Viral Load','Clients given 6C with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with <20 Copies Viral Load\n Clients given 6C with <20 Copies Viral Load\n \n 2023-08-17 16:11:36 UTC\n \n 2023-08-17 16:12:54 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2518\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:11:36',4,'2023-08-17 18:12:54',4,0,NULL,NULL,NULL,'b95e0670-059d-4690-986c-e7b162edc56a'),(2519,'Clients given 6C with Undetectable Viral Load','Clients given 6C with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6C with Undetectable Viral Load\n Clients given 6C with Undetectable Viral Load\n \n 2023-08-17 16:13:36 UTC\n \n 2023-08-17 16:14:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2519\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:13:36',4,'2023-08-17 18:14:33',4,0,NULL,NULL,NULL,'ef772750-6723-46e8-b1cd-2c843e8dd384'),(2520,'Clients given 6D with >=20Copies Viral Load','Clients given 6D with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with >=20Copies Viral Load\n Clients given 6D with >=20Copies Viral Load\n \n 2023-08-17 16:15:12 UTC\n \n 2023-08-17 16:16:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2520\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:15:12',4,'2023-08-17 18:16:15',4,0,NULL,NULL,NULL,'7067eaf1-d98c-4806-a595-c20526eb9695'),(2521,'Clients given 6D with <20 Copies Viral Load','Clients given 6D with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with <20 Copies Viral Load\n Clients given 6D with <20 Copies Viral Load\n \n 2023-08-17 16:17:05 UTC\n \n 2023-08-17 16:18:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2521\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:17:05',4,'2023-08-17 18:18:05',4,0,NULL,NULL,NULL,'cc8e5238-6071-4a37-b946-f6e9bf94dd26'),(2522,'Clients given 6D with Undetectable Viral Load','Clients given 6D with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6D with Undetectable Viral Load\n Clients given 6D with Undetectable Viral Load\n \n 2023-08-17 16:18:46 UTC\n \n 2023-08-17 16:19:45 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2522\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:18:46',4,'2023-08-17 18:19:45',4,0,NULL,NULL,NULL,'1df8beb0-cc67-496d-ba90-fa0dbc121691'),(2523,'Clients given 6E with >=20Copies Viral Load','Clients given 6E with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with >=20Copies Viral Load\n Clients given 6E with >=20Copies Viral Load\n \n 2023-08-17 16:20:29 UTC\n \n 2023-08-17 16:21:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2523\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:20:29',4,'2023-08-17 18:21:30',4,0,NULL,NULL,NULL,'6462e250-cf41-469a-83d7-e8b085ae587d'),(2524,'Clients given 6E with <20 Copies Viral Load','Clients given 6E with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with <20 Copies Viral Load\n Clients given 6E with <20 Copies Viral Load\n \n 2023-08-17 16:22:10 UTC\n \n 2023-08-17 16:24:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2524\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:22:10',4,'2023-08-17 18:24:14',4,0,NULL,NULL,NULL,'3492f4eb-af9b-448f-b4f1-fe314ce449f1'),(2525,'Children ARV Regimen_3rdLine_Adherence','Children ARV Regimen_3rdLine_Adherence','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_Adherence\n Children ARV Regimen_3rdLine_Adherence\n \n 2023-08-17 16:26:16 UTC\n \n 2023-08-17 16:26:28 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2525\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-17 18:26:16',4,'2023-08-17 18:26:28',4,0,NULL,NULL,NULL,'3262e4c0-f728-4cc8-ac30-b7413a14a644'),(2526,'Children ARV Regimen_3rdLine_Adherence Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_Adherence Data Set\n \n 2023-08-17 16:26:28 UTC\n \n 2023-08-17 16:38:11 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2526\n \n \n \n 6A_fair\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 6A_good\n \n \n \n \n \n \n \n \n \n 6A_poor\n \n \n \n \n \n \n \n \n \n 6B_fair\n \n \n \n \n \n \n \n \n \n 6B_good\n \n \n \n \n \n \n \n \n \n 6B_poor\n \n \n \n \n \n \n \n \n \n 6C_fair\n \n \n \n \n \n \n \n \n \n 6C_good\n \n \n \n \n \n \n \n \n \n 6C_poor\n \n \n \n \n \n \n \n \n \n 6D_fair\n \n \n \n \n \n \n \n \n \n 6D_good\n \n \n \n \n \n \n \n \n \n 6D_poor\n \n \n \n \n \n \n \n \n \n 6E_fair\n \n \n \n \n \n \n \n \n \n 6E_good\n \n \n \n \n \n \n \n \n \n 6E_poor\n \n \n \n \n \n \n \n \n \n 6F_fair\n \n \n \n \n \n \n \n \n \n 6F_good\n \n \n \n \n \n \n \n \n \n 6F_poor\n \n \n \n \n \n \n \n \n \n','2023-08-17 18:26:28',4,'2023-08-17 18:38:11',4,0,NULL,NULL,NULL,'9011d1b7-91da-465d-a4c7-38ea98126d13'),(2527,'Children ARV Regimen_2ndLine_Adherence','Children ARV Regimen_2ndLine_Adherence','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_Adherence\n Children ARV Regimen_2ndLine_Adherence\n \n 2023-08-17 16:40:24 UTC\n \n 2023-08-17 16:40:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2527\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-17 18:40:24',4,'2023-08-17 18:40:35',4,0,NULL,NULL,NULL,'ab24cc2a-a3ac-43a7-91c6-65bc90b27ae4'),(2528,'Children ARV Regimen_2ndLine_Adherence Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_Adherence Data Set\n \n 2023-08-17 16:40:35 UTC\n \n 2023-08-17 16:59:47 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2528\n \n \n \n 5A_fair\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 5A_good\n \n \n \n \n \n \n \n \n \n 5A_poor\n \n \n \n \n \n \n \n \n \n 5B_fair\n \n \n \n \n \n \n \n \n \n 5B_good\n \n \n \n \n \n \n \n \n \n 5B_poor\n \n \n \n \n \n \n \n \n \n 5C_fair\n \n \n \n \n \n \n \n \n \n 5C_good\n \n \n \n \n \n \n \n \n \n 5C_poor\n \n \n \n \n \n \n \n \n \n 5D_fair\n \n \n \n \n \n \n \n \n \n 5D_good\n \n \n \n \n \n \n \n \n \n 5D_poor\n \n \n \n \n \n \n \n \n \n 5E_fair\n \n \n \n \n \n \n \n \n \n 5E_good\n \n \n \n \n \n \n \n \n \n 5E_poor\n \n \n \n \n \n \n \n \n \n 5F_fair\n \n \n \n \n \n \n \n \n \n 5F_good\n \n \n \n \n \n \n \n \n \n 5F_poor\n \n \n \n \n \n \n \n \n \n 5G_fair\n \n \n \n \n \n \n \n \n \n 5G_good\n \n \n \n \n \n \n \n \n \n 5G_poor\n \n \n \n \n \n \n \n \n \n 5H_fair\n \n \n \n \n \n \n \n \n \n 5H_good\n \n \n \n \n \n \n \n \n \n 5H_poor\n \n \n \n \n \n \n \n \n \n','2023-08-17 18:40:35',4,'2023-08-17 18:59:47',4,0,NULL,NULL,NULL,'63956153-c9e8-480d-b057-96de951cf024'),(2529,'Clients given 6E with Undetectable Viral Load','Clients given 6E with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6E with Undetectable Viral Load\n Clients given 6E with Undetectable Viral Load\n \n 2023-08-17 16:48:58 UTC\n \n 2023-08-17 16:50:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2529\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:48:58',4,'2023-08-17 18:50:03',4,0,NULL,NULL,NULL,'836381fd-7adf-42ba-8ab4-01e9259a41f5'),(2530,'Clients given 6F with >=20Copies Viral Load','Clients given 6F with >=20Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with >=20Copies Viral Load\n Clients given 6F with >=20Copies Viral Load\n \n 2023-08-17 16:51:45 UTC\n \n 2023-08-17 16:53:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2530\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:51:45',4,'2023-08-17 18:53:52',4,0,NULL,NULL,NULL,'b8f0e53a-22a7-40e9-a9e6-e7ce266d4a19'),(2531,'Clients given 6F with <20 Copies Viral Load','Clients given 6F with <20 Copies Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with <20 Copies Viral Load\n Clients given 6F with <20 Copies Viral Load\n \n 2023-08-17 16:55:01 UTC\n \n 2023-08-17 16:58:01 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2531\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:55:01',4,'2023-08-17 18:58:01',4,0,NULL,NULL,NULL,'b820ee3d-d805-468d-b7b4-2d1c5ce10a92'),(2532,'Children ARV Regimen_3rdLine_Viral_Load','Children ARV Regimen_3rdLine_Viral_Load','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_Viral_Load\n Children ARV Regimen_3rdLine_Viral_Load\n \n 2023-08-17 16:58:13 UTC\n \n 2023-08-17 16:58:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2532\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-17 18:58:13',4,'2023-08-17 18:58:43',4,0,NULL,NULL,NULL,'72eeaaa5-8c87-4939-a657-99b15cc3ab35'),(2533,'Children ARV Regimen_3rdLine_Viral_Load Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_3rdLine_Viral_Load Data Set\n \n 2023-08-17 16:58:43 UTC\n \n 2023-08-17 17:29:02 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2533\n \n \n \n 6A<20\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 6A>=20\n \n \n \n \n \n \n \n \n \n 6AUndetect\n \n \n \n \n \n \n \n \n \n 6B<20\n \n \n \n \n \n \n \n \n \n 6B>=20\n \n \n \n \n \n \n \n \n \n 6BUndetect\n \n \n \n \n \n \n \n \n \n 6C<20\n \n \n \n \n \n \n \n \n \n 6C>=20\n \n \n \n \n \n \n \n \n \n 6CUndetect\n \n \n \n \n \n \n \n \n \n 6D<20\n \n \n \n \n \n \n \n \n \n 6D>=20\n \n \n \n \n \n \n \n \n \n 6DUndetect\n \n \n \n \n \n \n \n \n \n 6E<20\n \n \n \n \n \n \n \n \n \n 6E>=20\n \n \n \n \n \n \n \n \n \n 6EUndetect\n \n \n \n \n \n \n \n \n \n 6F<20\n \n \n \n \n \n \n \n \n \n 6F>=20\n \n \n \n \n \n \n \n \n \n 6FUndetect\n \n \n \n \n \n \n \n \n \n','2023-08-17 18:58:43',4,'2023-08-17 19:29:02',4,0,NULL,NULL,NULL,'0a51f76b-0306-47fa-947d-55305024054a'),(2534,'Clients given 6F with Undetectable Viral Load','Clients given 6F with Undetectable Viral Load','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients given 6F with Undetectable Viral Load\n Clients given 6F with Undetectable Viral Load\n \n 2023-08-17 16:59:07 UTC\n \n 2023-08-17 17:02:35 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2534\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-08-17 18:59:07',4,'2023-08-17 19:02:35',4,0,NULL,NULL,NULL,'b1f06b90-64db-4554-8e81-989e206ed34a'),(2535,'Children ARV Regimen_2ndLine_Viral_Load','Children ARV Regimen_2ndLine_Viral_Load','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_Viral_Load\n Children ARV Regimen_2ndLine_Viral_Load\n \n 2023-08-17 17:06:27 UTC\n \n 2023-08-17 17:06:48 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2535\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-08-17 19:06:27',4,'2023-08-17 19:06:48',4,0,NULL,NULL,NULL,'701df245-5766-4e37-9d54-89e6ecedb217'),(2536,'Children ARV Regimen_2ndLine_Viral_Load Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Children ARV Regimen_2ndLine_Viral_Load Data Set\n \n 2023-08-17 17:06:48 UTC\n \n 2023-10-26 13:43:01 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2536\n \n \n \n 5A_Undetec\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n 5A<20\n \n \n \n \n \n \n \n \n \n 5A>=20\n \n \n \n \n \n \n \n \n \n 5B_Undetec\n \n \n \n \n \n \n \n \n \n 5B<20\n \n \n \n \n \n \n \n \n \n 5B>=20\n \n \n \n \n \n \n \n \n \n 5C_Undetec\n \n \n \n \n \n \n \n \n \n 5C<20\n \n \n \n \n \n \n \n \n \n 5C>=20\n \n \n \n \n \n \n \n \n \n 5D_Undetec\n \n \n \n \n \n \n \n \n \n 5D<20\n \n \n \n \n \n \n \n \n \n 5D>=20\n \n \n \n \n \n \n \n \n \n 5E_Undetec\n \n \n \n \n \n \n \n \n \n 5E<20\n \n \n \n \n \n \n \n \n \n 5E>=20\n \n \n \n \n \n \n \n \n \n 5F_Undetec\n \n \n \n \n \n \n \n \n \n 5F<20\n \n \n \n \n \n \n \n \n \n 5F>=20\n \n \n \n \n \n \n \n \n \n 5G_Undetec\n \n \n \n \n \n \n \n \n \n 5G<20\n \n \n \n \n \n \n \n \n \n 5G>=20\n \n \n \n \n \n \n \n \n \n 5H_Undetec\n \n \n \n \n \n \n \n \n \n 5H<20\n \n \n \n \n \n \n \n \n \n 5H>=20\n \n \n \n \n \n \n \n \n \n','2023-08-17 19:06:48',4,'2023-10-26 15:43:01',4,0,NULL,NULL,NULL,'2790255e-587f-411d-9f8a-dbca36aa7e0d'),(2537,'ART clients with visits started','ART clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with visits started\n ART clients with visits started\n \n 2023-09-21 12:40:58 UTC\n \n 2023-09-21 12:41:15 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2537\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n LEFT JOIN patient_identifier pi ON v.patient_id = pi.patient_id AND pi.identifier_type in (5,12) \n JOIN patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1, 2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id and vt.visit_type_id in (10,19) \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:40:58',4,'2023-09-21 14:41:15',4,0,NULL,NULL,NULL,'5de36ef7-faa8-422d-943d-fdd6ad3497a0'),(2538,'ART clients with visits consulted','ART clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with visits consulted\n ART clients with visits consulted\n \n 2023-09-21 12:41:53 UTC\n \n 2023-09-21 12:42:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2538\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n LEFT JOIN patient_identifier pi ON v.patient_id = pi.patient_id AND pi.identifier_type in (5,12) \n JOIN patient_identifier_type pit on pi.identifier_type = pit.patient_identifier_type_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id and vt.visit_type_id in (10,19) \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id in (3843, 4276) and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:41:53',4,'2023-09-21 14:42:05',4,0,NULL,NULL,NULL,'9340a449-ab16-4a98-8dcb-240635a9042d'),(2539,'Clients initiated on ART this month','Clients initiated on ART this month','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients initiated on ART this month\n Clients initiated on ART this month\n \n 2023-09-21 12:42:21 UTC\n \n 2023-10-25 13:43:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2539\n select distinct patient.patient_id AS Id \n \n from obs o \n -- CLIENTS NEWLY INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 \n \n AND cast(o.value_datetime as date) >= (CAST(:startDate AS DATE)) \n AND cast(o.value_datetime as date) <= (CAST(:endDate AS DATE)) \n ) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id not in ( \n select distinct os.person_id from obs os \n where os.concept_id = 3634 \n AND os.value_coded = 2095 \n and os.voided = 0 \n AND cast(os.obs_datetime as date) >= (CAST(:startDate AS DATE)) \n AND cast(os.obs_datetime as date) <= (CAST(:endDate AS DATE)) \n ) \n \n and o.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages'\n','2023-09-21 14:42:21',4,'2023-10-25 15:43:32',4,0,NULL,NULL,NULL,'d3e386aa-99a9-4463-9e81-f663ca35cad2'),(2540,'TB clients with visits started','TB clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB clients with visits started\n TB clients with visits started\n \n 2023-09-21 12:42:50 UTC\n \n 2023-09-21 12:43:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2540\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 13 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:42:50',4,'2023-09-21 14:43:05',4,0,NULL,NULL,NULL,'e6d2d518-2160-4fc8-84dc-a680c609b27f'),(2541,'TB clients with visits consulted','TB clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB clients with visits consulted\n TB clients with visits consulted\n \n 2023-09-21 12:44:18 UTC\n \n 2023-09-21 12:45:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2541\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id in (4153,1158) and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 13 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:44:18',4,'2023-09-21 14:45:05',4,0,NULL,NULL,NULL,'d205535e-f890-488a-a256-a69835a9a9d8'),(2542,'HTS Clients Seen','HTS Clients Seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Clients Seen\n HTS Clients Seen\n \n 2023-09-21 12:45:02 UTC\n \n 2023-09-21 12:45:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2542\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in( \nSELECT Id \nFROM ( \n select distinct o.person_id as Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where o.concept_id = 4845 and o.value_coded = 4847 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n ) as A \n)\n','2023-09-21 14:45:02',4,'2023-09-21 14:45:39',4,0,NULL,NULL,NULL,'ce0fbba8-f81e-4f15-9da5-b341fd68b611'),(2543,'HTS clients with visits started','HTS clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS clients with visits started\n HTS clients with visits started\n \n 2023-09-21 12:45:52 UTC\n \n 2023-09-21 12:46:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2543\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 15 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:45:52',4,'2023-09-21 14:46:05',4,0,NULL,NULL,NULL,'fe7fb845-5325-4d00-8cab-7041e6759f04'),(2544,'1st Postnatal (PNC) Attendance','1st Postnatal (PNC) Attendance','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 1st Postnatal (PNC) Attendance\n 1st Postnatal (PNC) Attendance\n \n 2023-09-21 12:46:47 UTC\n \n 2023-09-21 12:47:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2544\n select \n o.person_id \nfrom obs o \ninner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4393 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4393 \n and o.obs_datetime = max_observation\n','2023-09-21 14:46:47',4,'2023-09-21 14:47:10',4,0,NULL,NULL,NULL,'290d3497-9608-4796-9826-1dc624696dbd'),(2545,'HTS clients with visits consulted','HTS clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS clients with visits consulted\n HTS clients with visits consulted\n \n 2023-09-21 12:47:27 UTC\n \n 2023-09-21 12:47:54 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2545\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4238 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 15 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:47:27',4,'2023-09-21 14:47:54',4,0,NULL,NULL,NULL,'35051ec1-423c-4ede-a68f-88e94f2dc6a2'),(2546,'Self test Kits distributed','Self test Kits distributed','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Self test Kits distributed\n Self test Kits distributed\n \n 2023-09-21 12:48:21 UTC\n \n 2023-09-21 12:48:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2546\n (select patient.patient_id AS Id \n from obs o \n -- HTS SELF TEST STRATEGY \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n AND o.concept_id = 4833 and o.value_coded = 4834 \n AND patient.voided = 0 AND o.voided = 0 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n ) \n \nUNION ALL \n(select patient.patient_id AS Id \n from obs o \n -- HTS SELF TEST STRATEGY \n INNER JOIN patient ON o.person_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n AND o.concept_id = 4836 and o.value_coded in (4837, 4838, 4839) \n AND patient.voided = 0 AND o.voided = 0 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n )\n','2023-09-21 14:48:21',4,'2023-09-21 14:48:36',4,0,NULL,NULL,NULL,'4ef31fd0-53cc-4296-adc1-1b74455e2a5f'),(2547,'ANC clients with visits started','ANC clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with visits started\n ANC clients with visits started\n \n 2023-09-21 12:49:04 UTC\n \n 2023-09-21 12:49:44 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2547\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 16 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:49:04',4,'2023-09-21 14:49:44',4,0,NULL,NULL,NULL,'928922c7-633f-4cb0-9149-88ae7e50e237'),(2548,'Under5 Clients Seen','Under5 Clients Seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under5 Clients Seen\n Under5 Clients Seen\n \n 2023-09-21 12:49:57 UTC\n \n 2023-09-21 12:50:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2548\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in( \nSELECT Id \nFROM ( \n select distinct o.person_id as Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where o.concept_id = 4285 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n ) as A \n)\n','2023-09-21 14:49:57',4,'2023-09-21 14:50:12',4,0,NULL,NULL,NULL,'93a89f3f-f556-4592-b12e-cf8849d58b58'),(2549,'ANC clients with visits consulted','ANC clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with visits consulted\n ANC clients with visits consulted\n \n 2023-09-21 12:50:25 UTC\n \n 2023-09-21 12:51:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2549\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4663 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 16 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:50:25',4,'2023-09-21 14:51:08',4,0,NULL,NULL,NULL,'ab0560b8-8a8b-4759-983b-d3b0d69afafa'),(2550,'HEI Clients Seen','HEI Clients Seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI Clients Seen\n HEI Clients Seen\n \n 2023-09-21 12:51:29 UTC\n \n 2023-09-21 12:51:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2550\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in( \nSELECT Id \nFROM ( \n select distinct o.person_id as Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where o.concept_id = 4558 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n ) as A \n)\n','2023-09-21 14:51:29',4,'2023-09-21 14:51:43',4,0,NULL,NULL,NULL,'f8e02920-02de-4c2b-9b44-6974b937b51c'),(2551,'PNC clients with visits started','PNC clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PNC clients with visits started\n PNC clients with visits started\n \n 2023-09-21 12:51:49 UTC\n \n 2023-09-21 12:52:21 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2551\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 17 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:51:49',4,'2023-09-21 14:52:21',4,0,NULL,NULL,NULL,'dddf7e03-38fe-419f-81a4-625dabb0fd4e'),(2552,'Family Planning Clients seen','Family Planning Clients seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning Clients seen\n Family Planning Clients seen\n \n 2023-09-21 12:52:28 UTC\n \n 2023-09-21 12:52:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2552\n select \n o.person_id \nfrom obs o \ninner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4557 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4557 \n and o.obs_datetime = max_observation\n','2023-09-21 14:52:28',4,'2023-09-21 14:52:43',4,0,NULL,NULL,NULL,'287d14af-8d53-48d0-8cf4-47f141b0e9ea'),(2553,'PNC clients with visits consulted','PNC clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PNC clients with visits consulted\n PNC clients with visits consulted\n \n 2023-09-21 12:52:50 UTC\n \n 2023-09-21 12:53:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2553\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4386 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 17 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:52:50',4,'2023-09-21 14:53:03',4,0,NULL,NULL,NULL,'bf6795b4-6d7f-49bd-aff7-53781f102898'),(2554,'Cervical Cancer Screening clients seen','Cervical Cancer Screening clients seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients seen\n Cervical Cancer Screening clients seen\n \n 2023-09-21 12:53:29 UTC\n \n 2023-10-17 13:11:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2554\n select \n o.person_id \nfrom obs o \ninner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 4511 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 4511 \n and o.obs_datetime = max_observation\n','2023-09-21 18:23:29',4,'2023-10-17 18:41:36',4,0,NULL,NULL,NULL,'f436cc71-62c7-413d-81b3-0f6bbad88a73'),(2555,'HEI clients with visits started','HEI clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI clients with visits started\n HEI clients with visits started\n \n 2023-09-21 12:54:17 UTC\n \n 2023-09-21 12:54:29 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2555\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 18 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:54:17',4,'2023-09-21 14:54:29',4,0,NULL,NULL,NULL,'e26ba5ce-54c6-4693-8f0c-52aae22ce97b'),(2556,'ANC Clients Seen','ANC Clients Seen','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients Seen\n ANC Clients Seen\n \n 2023-09-21 12:54:42 UTC\n \n 2023-09-21 12:54:57 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2556\n select distinct o.person_id \nfrom obs o inner join location l on o.location_id = l.location_id \nwhere (o.location_id =:location or parent_location =:location) \nand o.person_id in( \nSELECT Id \nFROM ( \n select distinct o.person_id as Id \n from obs o \n INNER JOIN patient ON o.person_id = patient.patient_id \n where o.concept_id = 4663 \n AND CAST(o.obs_datetime AS DATE) >= CAST(:startDate AS DATE) \n AND CAST(o.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n AND patient.voided = 0 AND o.voided = 0 \n ) as A \n)\n','2023-09-21 14:54:42',4,'2023-09-21 14:54:57',4,0,NULL,NULL,NULL,'f58dd29e-bfcf-411a-a5fa-789722177fd1'),(2557,'HEI clients with visits consulted','HEI clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI clients with visits consulted\n HEI clients with visits consulted\n \n 2023-09-21 12:55:13 UTC\n \n 2023-09-21 12:56:33 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2557\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id in (4558, 4186) and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 18 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:55:13',4,'2023-09-21 14:56:33',4,0,NULL,NULL,NULL,'2bcc29bb-b22f-4866-8035-f7f1db1ead87'),(2558,'ANC Clients Seen','ANC Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC Clients Seen\n ANC Clients Seen\n \n 2023-09-21 12:55:47 UTC\n \n 2023-09-21 12:56:41 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2558\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 14:55:47',4,'2023-09-21 14:56:41',4,0,NULL,NULL,NULL,'7006c9eb-caa2-4617-9151-d6872b35e3a1'),(2559,'Cervical Cancer Screening clients seen','Cervical Cancer Screening clients seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients seen\n Cervical Cancer Screening clients seen\n \n 2023-09-21 12:57:08 UTC\n \n 2023-09-21 12:57:52 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2559\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 14:57:08',4,'2023-09-21 14:57:52',4,0,NULL,NULL,NULL,'697c637f-d0ae-45a2-9eab-f4f9012c2412'),(2560,'Family Planning clients with visits started','Family Planning clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning clients with visits started\n Family Planning clients with visits started\n \n 2023-09-21 12:57:35 UTC\n \n 2023-09-21 12:57:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2560\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 22 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:57:35',4,'2023-09-21 14:57:59',4,0,NULL,NULL,NULL,'a713664a-9547-4de1-bcea-eab77e351ec5'),(2561,'Family Planning Clients seen','Family Planning Clients seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning Clients seen\n Family Planning Clients seen\n \n 2023-09-21 12:58:35 UTC\n \n 2023-09-21 12:59:30 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2561\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 14:58:35',4,'2023-09-21 14:59:30',4,0,NULL,NULL,NULL,'4934d5cb-a141-4144-9937-59b8bb142789'),(2562,'Family Planning clients with visits consulted','Family Planning clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning clients with visits consulted\n Family Planning clients with visits consulted\n \n 2023-09-21 12:58:46 UTC\n \n 2023-09-21 12:59:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2562\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4557 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 22 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:58:46',4,'2023-09-21 14:59:18',4,0,NULL,NULL,NULL,'ada60155-c22d-4ad4-b960-45bb814acd47'),(2563,'HEI Clients Seen','HEI Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI Clients Seen\n HEI Clients Seen\n \n 2023-09-21 12:59:50 UTC\n \n 2023-09-21 13:00:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2563\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 14:59:50',4,'2023-09-21 15:00:32',4,0,NULL,NULL,NULL,'8f5713d9-1797-48ed-92ba-7a6bbc3f02be'),(2564,'Under 5 clients with visits started','Under 5 clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under 5 clients with visits started\n Under 5 clients with visits started\n \n 2023-09-21 12:59:58 UTC\n \n 2023-09-21 13:00:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2564\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 20 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 14:59:58',4,'2023-09-21 15:00:12',4,0,NULL,NULL,NULL,'b569e5c1-aab8-4a67-955c-b09d0c5c1b6b'),(2565,'Under 5 clients with visits consulted','Under 5 clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under 5 clients with visits consulted\n Under 5 clients with visits consulted\n \n 2023-09-21 13:00:57 UTC\n \n 2023-09-21 13:01:12 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2565\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4285 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 20 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 15:00:57',4,'2023-09-21 15:01:12',4,0,NULL,NULL,NULL,'ae2b5eee-422b-4307-a985-7bd763147582'),(2566,'HTS Clients Seen','HTS Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS Clients Seen\n HTS Clients Seen\n \n 2023-09-21 13:00:59 UTC\n \n 2023-09-21 13:01:59 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2566\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:00:59',4,'2023-09-21 15:01:59',4,0,NULL,NULL,NULL,'198319c7-6986-4599-8b2a-886ed81d7c37'),(2567,'1st Postnatal (PNC) Attendance','1st Postnatal (PNC) Attendance','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n 1st Postnatal (PNC) Attendance\n 1st Postnatal (PNC) Attendance\n \n 2023-09-21 13:01:44 UTC\n \n 2023-09-21 13:02:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2567\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:01:44',4,'2023-09-21 15:02:26',4,0,NULL,NULL,NULL,'07589d1a-d289-491c-a8dd-ac6e506b6eca'),(2568,'Cervical Cancer Screening clients with visits started','Cervical Cancer Screening clients with visits started','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients with visits started\n Cervical Cancer Screening clients with visits started\n \n 2023-09-21 13:02:00 UTC\n \n 2023-09-21 13:02:14 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2568\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 21 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 15:02:00',4,'2023-09-21 15:02:14',4,0,NULL,NULL,NULL,'4f7cc18d-1104-4427-b582-f73b99bd0837'),(2569,'Self test Kits distributed','Self test Kits distributed','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Self test Kits distributed\n Self test Kits distributed\n \n 2023-09-21 13:02:50 UTC\n \n 2023-09-21 13:04:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2569\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:02:50',4,'2023-09-21 15:04:03',4,0,NULL,NULL,NULL,'5cc879f5-78be-4f74-9cd0-06ae596deffe'),(2570,'Cervical Cancer Screening clients with visits consulted','Cervical Cancer Screening clients with visits consulted','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients with visits consulted\n Cervical Cancer Screening clients with visits consulted\n \n 2023-09-21 13:02:56 UTC\n \n 2023-09-21 13:03:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2570\n select distinct o.person_id \nfrom obs o \nwhere o.person_id in \n ( \n SELECT DISTINCT p.person_id as id \n FROM visit v \n JOIN person_name pn on v.patient_id = pn.person_id and pn.voided=0 \n JOIN person p on p.person_id = v.patient_id \n JOIN encounter en on en.visit_id = v.visit_id and en.voided=0 and en.encounter_type in (1,2) \n JOIN visit_type vt on vt.visit_type_id = vt.visit_type_id \n JOIN obs o on o.encounter_id=en.encounter_id \n and o.concept_id = 4511 and o.voided =0 \n JOIN location l on v.location_id = l.location_id and l.retired=0 \n WHERE CAST(en.encounter_datetime AS DATE) >= CAST(:startDate AS DATE) and CAST(en.encounter_datetime AS DATE)<= CAST(:endDate AS DATE) \n and v.visit_type_id = 21 \n and (v.location_id = :location or parent_location = :location) \n \n )\n','2023-09-21 15:02:56',4,'2023-09-21 15:03:08',4,0,NULL,NULL,NULL,'cf21c6a3-0a19-44c7-b2c7-e14246d7bc96'),(2571,'Under5 Clients Seen','Under5 Clients Seen','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under5 Clients Seen\n Under5 Clients Seen\n \n 2023-09-21 13:03:36 UTC\n \n 2023-09-21 13:05:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2571\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:03:36',4,'2023-09-21 15:05:20',4,0,NULL,NULL,NULL,'d8654256-acae-40b0-a3c2-feafeb2f36ad'),(2572,'eRegister Monitoring Report','eRegister Monitoring Report','org.openmrs.module.reporting.report.definition.ReportDefinition','org.openmrs.module.reporting.report.definition.PeriodIndicatorReportDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n eRegister Monitoring Report\n eRegister Monitoring Report\n \n 2023-09-21 13:06:13 UTC\n \n 2023-09-21 13:26:06 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2572\n \n \n defaultDataSet\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n','2023-09-21 15:06:13',4,'2023-09-21 15:26:06',4,0,NULL,NULL,NULL,'a9290709-3dd9-4bfe-823d-b1702d10ec0f'),(2573,'eRegister Monitoring Report Data Set',NULL,'org.openmrs.module.reporting.dataset.definition.DataSetDefinition','org.openmrs.module.reporting.dataset.definition.CohortIndicatorDataSetDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n eRegister Monitoring Report Data Set\n \n 2023-09-21 13:06:21 UTC\n \n 2023-09-22 08:47:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2573\n \n \n \n ANC_Consul\n \n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n \n \n \n \n ANC_Seen\n \n \n \n \n \n \n \n \n \n ANC_Visits\n \n \n \n \n \n \n \n \n \n ART_Consul\n \n \n \n \n \n \n \n \n \n ART_Visits\n \n \n \n \n \n \n \n \n \n Cerv_Consu\n \n \n \n \n \n \n \n \n \n Cerv_Scree\n \n \n \n \n \n \n \n \n \n Cerv_Visit\n \n \n \n \n \n \n \n \n \n ClntsOnArt\n \n \n \n \n \n \n \n \n \n FP_Consult\n \n \n \n \n \n \n \n \n \n FP_Seen\n \n \n \n \n \n \n \n \n \n FP_Visits\n \n \n \n \n \n \n \n \n \n HEI_Consul\n \n \n \n \n \n \n \n \n \n HEI_Seen\n \n \n \n \n \n \n \n \n \n HEI_Visits\n \n \n \n \n \n \n \n \n \n HTS_Consul\n \n \n \n \n \n \n \n \n \n HTS_Seen\n \n \n \n \n \n \n \n \n \n HTS_Visits\n \n \n \n \n \n \n \n \n \n LTest_Rev\n \n \n \n \n \n \n \n \n \n LTest_Sent\n \n \n \n \n \n \n \n \n \n PNC_Attend\n \n \n \n \n \n \n \n \n \n PNC_Consul\n \n \n \n \n \n \n \n \n \n PNC_Visits\n \n \n \n \n \n \n \n \n \n Self_tes_D\n \n \n \n \n \n \n \n \n \n TB_Consult\n \n \n \n \n \n \n \n \n \n TB_Visits\n \n \n \n \n \n \n \n \n \n Tx_New\n \n \n \n \n \n \n \n \n \n Under5_Con\n \n \n \n \n \n \n \n \n \n Under5_See\n \n \n \n \n \n \n \n \n \n Under5_Vis\n \n \n \n \n \n \n \n \n \n','2023-09-21 13:06:21',4,'2023-09-22 08:47:46',4,0,NULL,NULL,NULL,'a971d8e2-a66a-487c-aae4-36c6f14a3328'),(2574,' ANC clients with visits started',' ANC clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with visits started\n ANC clients with visits started\n \n 2023-09-21 13:07:00 UTC\n \n 2023-09-21 13:07:46 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2574\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:07:00',4,'2023-09-21 15:07:46',4,0,NULL,NULL,NULL,'69485106-52a5-452e-91ef-6ecf80894a7f'),(2575,'ART clients with visits consulted','ART clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with visits consulted\n ART clients with visits consulted\n \n 2023-09-21 13:08:16 UTC\n \n 2023-09-21 13:08:50 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2575\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:08:16',4,'2023-09-21 15:08:50',4,0,NULL,NULL,NULL,'7cce44cb-0809-4493-84bb-2fdbe745ceab'),(2576,'ART clients with visits started','ART clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ART clients with visits started\n ART clients with visits started\n \n 2023-09-21 13:09:47 UTC\n \n 2023-09-21 13:11:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2576\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:09:47',4,'2023-09-21 15:11:10',4,0,NULL,NULL,NULL,'a5551436-00f8-45c4-aa3b-6aaae3160f55'),(2577,'Clients initiated on ART this month','Clients initiated on ART this month','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients initiated on ART this month\n Clients initiated on ART this month\n \n 2023-09-21 13:11:24 UTC\n \n 2023-09-21 13:12:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2577\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:11:24',4,'2023-09-21 15:12:20',4,0,NULL,NULL,NULL,'e6b92d7a-5f7e-4001-957e-30b6be452168'),(2578,'ANC clients with visits consulted','ANC clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n ANC clients with visits consulted\n ANC clients with visits consulted\n \n 2023-09-21 13:11:45 UTC\n \n 2023-09-21 13:12:58 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2578\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:11:45',4,'2023-09-21 15:12:58',4,0,NULL,NULL,NULL,'5c7fcfb9-3d39-4225-a4f3-8ed358e16626'),(2579,'TB clients with visits started','TB clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB clients with visits started\n TB clients with visits started\n \n 2023-09-21 13:13:10 UTC\n \n 2023-09-21 13:13:56 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2579\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:13:10',4,'2023-09-21 15:13:56',4,0,NULL,NULL,NULL,'09767de3-79b3-43e2-82da-339278f5e10d'),(2580,'TB clients with visits consulted','TB clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n TB clients with visits consulted\n TB clients with visits consulted\n \n 2023-09-21 13:14:13 UTC\n \n 2023-09-21 13:16:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2580\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:14:13',4,'2023-09-21 15:16:03',4,0,NULL,NULL,NULL,'d4ae74d3-d618-4e3b-8d10-4c54e5f3b75a'),(2581,'HTS clients with visits started','HTS clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS clients with visits started\n HTS clients with visits started\n \n 2023-09-21 13:16:45 UTC\n \n 2023-09-21 13:17:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2581\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:16:45',4,'2023-09-21 15:17:18',4,0,NULL,NULL,NULL,'91f470f1-71bf-4a21-bd12-efe0fe142c0a'),(2582,'HTS clients with visits consulted','HTS clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HTS clients with visits consulted\n HTS clients with visits consulted\n \n 2023-09-21 13:17:44 UTC\n \n 2023-09-21 13:18:19 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2582\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:17:44',4,'2023-09-21 15:18:19',4,0,NULL,NULL,NULL,'2bd858aa-2daf-4fd2-9028-9d6fba579a89'),(2583,'PNC clients with visits started','PNC clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PNC clients with visits started\n PNC clients with visits started\n \n 2023-09-21 13:18:49 UTC\n \n 2023-09-21 13:19:20 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2583\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:18:49',4,'2023-09-21 15:19:20',4,0,NULL,NULL,NULL,'80003d94-268b-4726-ba0d-0fa830e90463'),(2584,'PNC clients with visits consulted','PNC clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n PNC clients with visits consulted\n PNC clients with visits consulted\n \n 2023-09-21 13:19:39 UTC\n \n 2023-09-21 13:20:18 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2584\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:19:39',4,'2023-09-21 15:20:18',4,0,NULL,NULL,NULL,'e64fd32d-8284-4fb5-a227-8f338859ceaa'),(2586,'HEI clients with visits started','HEI clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI clients with visits started\n HEI clients with visits started\n \n 2023-09-21 13:23:38 UTC\n \n 2023-09-21 13:24:10 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2586\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:23:38',4,'2023-09-21 15:24:10',4,0,NULL,NULL,NULL,'e7e581aa-9b90-4f56-b8a1-9bfc607f8b4f'),(2587,'HEI clients with visits consulted','HEI clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n HEI clients with visits consulted\n HEI clients with visits consulted\n \n 2023-09-21 13:24:38 UTC\n \n 2023-09-21 13:25:05 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2587\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:24:38',4,'2023-09-21 15:25:05',4,0,NULL,NULL,NULL,'dd05778e-c5bd-4430-90fa-fd97b36402d2'),(2588,'Family Planning clients with visits started','Family Planning clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning clients with visits started\n Family Planning clients with visits started\n \n 2023-09-21 13:25:31 UTC\n \n 2023-09-21 13:26:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2588\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:25:31',4,'2023-09-21 15:26:32',4,0,NULL,NULL,NULL,'3278fb6f-2276-4390-a5c2-9863d056f3a0'),(2589,'Family Planning clients with visits consulted','Family Planning clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Family Planning clients with visits consulted\n Family Planning clients with visits consulted\n \n 2023-09-21 13:26:58 UTC\n \n 2023-09-21 13:27:32 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2589\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:26:58',4,'2023-09-21 15:27:32',4,0,NULL,NULL,NULL,'822f0677-6a2b-47cf-9265-0841d65e9716'),(2590,'Under 5 clients with visits consulted','Under 5 clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under 5 clients with visits consulted\n Under 5 clients with visits consulted\n \n 2023-09-21 13:28:28 UTC\n \n 2023-09-21 13:31:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2590\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:28:28',4,'2023-09-21 15:31:36',4,0,NULL,NULL,NULL,'3a2857b0-1d9c-4f7d-95e9-abcba540935d'),(2591,'Under 5 clients with visits started','Under 5 clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Under 5 clients with visits started\n Under 5 clients with visits started\n \n 2023-09-21 13:30:05 UTC\n \n 2023-09-21 13:30:36 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2591\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:30:05',4,'2023-09-21 15:30:36',4,0,NULL,NULL,NULL,'f62e6fdd-a64b-4619-925c-d86fc3987060'),(2592,'Clients current on ART','Clients current on ART','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients current on ART\n Clients current on ART\n \n 2023-09-21 13:31:58 UTC\n \n 2023-09-21 13:35:41 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2592\n (SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- CLIENTS NEWLY INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 \n \n AND MONTH(o.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id not in ( \n select distinct os.person_id from obs os \n where os.concept_id = 3634 \n AND os.value_coded = 2095 \n and os.voided = 0 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n and o.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages') AS Newly_Initiated_ART_Clients \nORDER BY Newly_Initiated_ART_Clients.patientName) \n \nUNION \n \n(SELECT Id \nFROM ( \n \nselect distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n observed_age_group.sort_order AS sort_order \n from obs o \n -- CLIENTS SEEN FOR ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 3843 AND o.value_coded = 3841 OR o.value_coded = 3842) \n AND MONTH(o.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND patient.voided = 0 AND o.voided = 0 \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages' \n \n) AS Clients_Seen \n \nWHERE Clients_Seen.Id not in ( \n select distinct patient.patient_id AS Id \n from obs o \n -- CLIENTS INITIATED ON ART \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND (o.concept_id = 2249 \n AND MONTH(o.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(o.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n AND patient.voided = 0 AND o.voided = 0 \n AND o.person_id not in ( \n select distinct os.person_id from obs os \n where os.concept_id = 3634 \n AND os.value_coded = 2095 \n and os.voided = 0 \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n ) \n \n ) \nAND Clients_Seen.Id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 and os.voided = 0 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 and os.voided = 0 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \nAND Clients_Seen.Id not in \n ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 and os.voided = 0 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) \n and o.person_id in ( \n -- Death \n select distinct p.person_id \n from person p \n where dead = 1 \n and death_date <= CAST(:endDate AS DATE) \n and voided = 0 \n ) \n ) \nAND Clients_Seen.Id not in ( \n -- Visitors \n select o.person_id \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 5416 and oss.value_coded =1 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 5416 \n and o.obs_datetime = max_observation \n ) \n \nORDER BY Clients_Seen.patientName) \n \nUNION \n \n \n-- INCLUDE MISSED APPOINTMENTS WITHIN 28 DAYS ACCORDING TO THE NEW PEPFAR GUIDELINE \n(SELECT Id \nFROM \n (select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n -- CLIENTS WHO MISSED APPOINTMENTS < 28 DAYS \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n -- begin \n select active_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up < cast(:endDate as date) \n and DATEDIFF(CAST(:endDate AS DATE),latest_follow_up) <= 28 \n \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 3843 AND os.value_coded = 3841 OR os.value_coded = 3842) \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n and os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n \n -- TOUTS \n select tout_clients.person_id \n from \n (select B.person_id, B.obs_group_id, B.obs_datetime AS latest_consultation \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(max(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 2403 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 2398 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as tout_clients \n where tout_clients.latest_consultation < cast(:endDate as date) \n \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n \n ) \n \n and active_clients.person_id not in( \n -- Visitors \n select o.person_id \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 5416 and oss.value_coded =1 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 5416 \n and o.obs_datetime = max_observation \n ) \n ) \n -- end \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages') AS TwentyEightDayDefaulters \n order by TwentyEightDayDefaulters.patientName) \n \n \nUNION \n \n(SELECT Id \n FROM \n (select distinct patient.patient_id AS Id, \n patient_identifier.identifier AS patientIdentifier, \n concat(person_name.given_name, ' ', person_name.family_name) AS patientName, \n floor(datediff(CAST(:endDate AS DATE), person.birthdate)/365) AS Age, \n person.gender AS Gender, \n observed_age_group.name AS age_group, \n observed_age_group.sort_order AS sort_order \n \n from obs o \n \n INNER JOIN patient ON o.person_id = patient.patient_id \n AND o.person_id in ( \n -- begin \n select active_clients.person_id-- , active_clients.latest_follow_up \n from \n (select B.person_id, B.obs_group_id, B.value_datetime AS latest_follow_up \n from obs B \n inner join \n (select person_id, max(obs_datetime), SUBSTRING(MAX(CONCAT(obs_datetime, obs_id)), 20) AS observation_id \n from obs where concept_id = 3753 \n and obs_datetime <= cast(:endDate as date) \n and voided = 0 \n group by person_id) as A \n on A.observation_id = B.obs_group_id \n where concept_id = 3752 \n and A.observation_id = B.obs_group_id \n and voided = 0 \n group by B.person_id \n ) as active_clients \n where active_clients.latest_follow_up >= cast(:endDate as date) \n \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where (os.concept_id = 3843 AND os.value_coded = 3841 OR os.value_coded = 3842) \n AND MONTH(os.obs_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.obs_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct os.person_id \n from obs os \n where concept_id = 2249 \n AND MONTH(os.value_datetime) = MONTH(CAST(:endDate AS DATE)) \n AND YEAR(os.value_datetime) = YEAR(CAST(:endDate AS DATE)) \n AND os.voided = 0 \n ) \n \n and active_clients.person_id not in ( \n select distinct(o.person_id) \n from obs o \n where o.person_id in ( \n -- FOLLOW UPS \n select firstquery.person_id \n from \n ( \n select oss.person_id, SUBSTRING(MAX(CONCAT(oss.value_datetime, oss.obs_id)), 20) AS observation_id, CAST(max(oss.value_datetime) AS DATE) as latest_followup_obs \n from obs oss \n where oss.voided=0 \n and oss.concept_id=3752 \n and CAST(oss.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n and CAST(oss.obs_datetime AS DATE) >= DATE_ADD(CAST(:endDate AS DATE), INTERVAL -13 MONTH) \n group by oss.person_id) firstquery \n inner join ( \n select os.person_id,datediff(CAST(max(os.value_datetime) AS DATE), CAST(:endDate AS DATE)) as last_ap \n from obs os \n where concept_id = 3752 and os.voided = 0 \n and CAST(os.obs_datetime AS DATE) <= CAST(:endDate AS DATE) \n group by os.person_id \n having last_ap < 0 \n ) secondquery \n on firstquery.person_id = secondquery.person_id \n ) and o.person_id in ( \n -- TOUTS \n select distinct(person_id) \n from \n ( \n select os.person_id, CAST(max(os.value_datetime) AS DATE) as latest_transferout \n from obs os \n where os.concept_id=2266 and os.voided = 0 \n group by os.person_id \n having latest_transferout <= CAST(:endDate AS DATE) \n ) as TOUTS \n ) \n ) \n \n \n and active_clients.person_id not in ( \n select person_id \n from person \n where death_date <= cast(:endDate as date) \n and dead = 1 and voided = 0 \n ) \n and active_clients.person_id not in ( \n -- Visitors \n select o.person_id \n from obs o \n inner join \n ( \n select oss.person_id, MAX(oss.obs_datetime) as max_observation, \n SUBSTRING(MAX(CONCAT(oss.obs_datetime, oss.value_coded)), 20) as examination_timing \n from obs oss \n where oss.concept_id = 5416 and oss.value_coded =1 and oss.voided=0 \n and cast(oss.obs_datetime as date) >= cast(:startDate as date) \n and cast(oss.obs_datetime as date) <= cast(:endDate as date) \n group by oss.person_id \n )latest \n on latest.person_id = o.person_id \n where concept_id = 5416 \n and o.obs_datetime = max_observation \n ) \n ) \n -- end \n \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id AND person_name.preferred = 1 \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n INNER JOIN reporting_age_group AS observed_age_group ON \n CAST(:endDate AS DATE) BETWEEN (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.min_years YEAR), INTERVAL observed_age_group.min_days DAY)) \n AND (DATE_ADD(DATE_ADD(person.birthdate, INTERVAL observed_age_group.max_years YEAR), INTERVAL observed_age_group.max_days DAY)) \n WHERE observed_age_group.report_group_name = 'Modified_Ages') AS Seen_Previous_ART_Clients \nORDER BY Seen_Previous_ART_Clients.patientName) \n\n','2023-09-21 15:31:58',4,'2023-09-21 15:35:41',4,0,NULL,NULL,NULL,'ad403c3b-d759-44ab-8965-252ca6127ce7'),(2593,'Cervical Cancer Screening clients with visits started','Cervical Cancer Screening clients with visits started','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients with visits started\n Cervical Cancer Screening clients with visits started\n \n 2023-09-21 13:32:10 UTC\n \n 2023-09-21 13:32:43 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2593\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:32:10',4,'2023-09-21 15:32:43',4,0,NULL,NULL,NULL,'c7967fcd-a8b7-41d4-b540-364a60a59621'),(2594,'Cervical Cancer Screening clients with visits consulted','Cervical Cancer Screening clients with visits consulted','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Cervical Cancer Screening clients with visits consulted\n Cervical Cancer Screening clients with visits consulted\n \n 2023-09-21 13:33:06 UTC\n \n 2023-09-21 13:34:03 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2594\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:33:06',4,'2023-09-21 15:34:03',4,0,NULL,NULL,NULL,'b526566e-555d-40c6-88d4-0b89242b1dde'),(2595,'Clients current on ART','Clients current on ART','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients current on ART\n Clients current on ART\n \n 2023-09-21 13:36:28 UTC\n \n 2023-09-21 13:37:08 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2595\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-21 15:36:28',4,'2023-09-21 15:37:08',4,0,NULL,NULL,NULL,'1db1c64d-177f-4ecc-b1d7-c9fd2b029eff'),(2596,'Clients with LAB tests sent','Clients with LAB tests sent','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with LAB tests sent\n Clients with LAB tests sent\n \n 2023-09-22 08:35:11 UTC\n \n 2023-09-22 08:35:51 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2596\n select distinct patient.patient_id AS Id \n from orders o \n INNER JOIN patient ON o.patient_id = patient.patient_id \n INNER JOIN person ON person.person_id = patient.patient_id AND person.voided = 0 \n INNER JOIN person_name ON person.person_id = person_name.person_id \n INNER JOIN patient_identifier ON patient_identifier.patient_id = person.person_id AND patient_identifier.identifier_type = 3 AND patient_identifier.preferred=1 \n AND o.concept_id = 5484 \n AND CAST(o.date_created AS DATE)>= CAST(:startDate AS DATE) \n AND CAST(o.date_created AS DATE) <= CAST(:endDate AS DATE) \n LEFT OUTER JOIN patient_identifier p ON p.patient_id = person.person_id AND p.identifier_type = 5\n','2023-09-22 08:35:11',4,'2023-09-22 08:35:51',4,0,NULL,NULL,NULL,'f06f1ccb-c048-44d3-8037-35f8660a6b95'),(2597,'Clients with LAB tests sent','Clients with LAB tests sent','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with LAB tests sent\n Clients with LAB tests sent\n \n 2023-09-22 08:36:30 UTC\n \n 2023-09-22 08:38:26 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2597\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-22 08:36:30',4,'2023-09-22 08:38:26',4,0,NULL,NULL,NULL,'c29cff5d-5919-4b60-8ab7-c6d4c7ea01da'),(2598,'Clients with LAB tests received','Clients with LAB tests received','org.openmrs.module.reporting.cohort.definition.CohortDefinition','org.openmrs.module.reporting.cohort.definition.SqlCohortDefinition','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with LAB tests received\n Clients with LAB tests received\n \n 2023-09-22 08:39:02 UTC\n \n 2023-10-25 13:32:17 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2598\n Select pId \n From \n ( \n select oss.person_id as pId, concat(oss.value_numeric, " ", "copies/ml") as Results \n from obs oss \n where oss.concept_id = 5485 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast('#endDate#' as date) \n group by oss.person_id \n \n UNION \n \n select oss.person_id as pId, "LDL" as Results \n from obs oss \n where oss.concept_id = 5489 \n and oss.voided=0 \n and cast(oss.obs_datetime as date) <= cast('#endDate#' as date) \n group by oss.person_id \n \n ) As received_results\n','2023-09-22 10:39:02',4,'2023-10-25 15:32:17',4,0,NULL,NULL,NULL,'6939902b-1909-4f24-b71d-da60ab1d131b'),(2599,'Clients with LAB tests received','Clients with LAB tests received','org.openmrs.module.reporting.indicator.Indicator','org.openmrs.module.reporting.indicator.CohortIndicator','org.openmrs.module.reporting.serializer.ReportingSerializer','\n Clients with LAB tests received\n Clients with LAB tests received\n \n 2023-09-22 08:39:53 UTC\n \n 2023-09-22 08:42:39 UTC\n \n \n startDate\n \n java.util.Date\n true\n \n \n endDate\n \n java.util.Date\n true\n \n \n location\n \n org.openmrs.Location\n true\n \n \n 2599\n COUNT\n \n \n \n \n endDate\n ${endDate}\n \n \n location\n ${location}\n \n \n startDate\n ${startDate}\n \n \n \n','2023-09-22 08:39:53',4,'2023-09-22 08:42:39',4,0,NULL,NULL,NULL,'e47a29f8-b851-480f-9812-e54da393fdb9'); /*!40000 ALTER TABLE `serialized_object` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -84,4 +84,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2023-10-17 19:53:00 +-- Dump completed on 2023-10-26 15:44:33